Просмотр исходного кода

Merge branch 'master' of https://github.com/unaio/una

AntonLV 6 лет назад
Родитель
Сommit
035dacea55

+ 2 - 3
modules/base/text/classes/BxBaseModTextModule.php

@@ -704,8 +704,8 @@ class BxBaseModTextModule extends BxBaseModGeneralModule implements iBxDolConten
         $CNF = &$this->_oConfig->CNF;
 
         $bDynamic = isset($aBrowseParams['dynamic_mode']) && (bool)$aBrowseParams['dynamic_mode'] === true;
-
-        $aPolls = $this->_oDb->getPolls(array('type' => 'content_id', 'content_id' => (int)$aContentInfo[$CNF['FIELD_ID']]));
+		if(!empty($CNF['PARAM_POLL_ENABLED']) && $CNF['PARAM_POLL_ENABLED'] == true)
+        	$aPolls = $this->_oDb->getPolls(array('type' => 'content_id', 'content_id' => (int)$aContentInfo[$CNF['FIELD_ID']]));
         if(!empty($aPolls) && is_array($aPolls)) {
             $sInclude = $this->_oTemplate->addCss(array('polls.css'), $bDynamic);
 
@@ -721,7 +721,6 @@ class BxBaseModTextModule extends BxBaseModGeneralModule implements iBxDolConten
                 $aResult['_cache'] = false;
  */
         }
-
         return $aResult;
     }
 

+ 3 - 0
modules/boonex/organizations/classes/BxOrgsAlertsResponse.php

@@ -28,6 +28,9 @@ class BxOrgsAlertsResponse extends BxBaseModGroupsAlertsResponse
 
     protected function processAccountCheckSwitchContext(&$oAlert)
     {
+        if ($oAlert->aExtras['override_result'])
+            return;
+        
         $iProfile = (int)$oAlert->aExtras['switch_to_profile'];
         $oProfile = BxDolProfile::getInstance($iProfile);
         if(!$oProfile || $oProfile->getModule() != $this->_oModule->_oConfig->getName())

+ 65 - 3
modules/boonex/tasks/classes/BxTasksModule.php

@@ -42,10 +42,18 @@ class BxTasksModule extends BxBaseModTextModule implements iBxDolCalendarService
         echo(json_encode($a));
     }
           
-    public function actionSetCompleted($iTaskId, $iValue)
+    public function actionSetCompleted($iContentId, $iValue)
     {
 		$CNF = &$this->_oConfig->CNF;
-		$this->_oDb->updateEntriesBy(array($CNF['FIELD_COMPLETED'] => $iValue), array($CNF['FIELD_ID'] => (int)$iTaskId));
+		$this->_oDb->updateEntriesBy(array($CNF['FIELD_COMPLETED'] => $iValue), array($CNF['FIELD_ID'] => (int)$iContentId));
+		$sActionName = 'completed';
+		if ($iValue == '0')
+			$sActionName = 'reopened';
+		
+		$aContentInfo = $this->_oDb->getContentInfoById($iContentId);
+        $aParams = $this->_alertParams($aContentInfo);
+		
+		bx_alert($this->getName(), $sActionName, $iContentId, $aContentInfo[$CNF['FIELD_AUTHOR']], $aParams);
 		echo 'ok';
 	}
 	
@@ -129,7 +137,9 @@ class BxTasksModule extends BxBaseModTextModule implements iBxDolCalendarService
         if($oForm->isSubmittedAndValid()) {
 			$aValsToAdd[$CNF['FIELD_ALLOW_VIEW_TO']] = $iContextId;
 			$aValsToAdd[$CNF['FIELD_TASKLIST']] = $iListId;
-			$iId = $oForm->insert($aValsToAdd);
+			$iContentId = $oForm->insert($aValsToAdd);
+			$this->onPublished($iContentId);
+			
 			return echoJson(array(
 				 'eval' => $this->_oConfig->getJsObject('tasks') . '.reloadData(oData)',
 			));
@@ -166,6 +176,30 @@ class BxTasksModule extends BxBaseModTextModule implements iBxDolCalendarService
         echo json_encode($aEntries);
     }
 	
+	/**
+     * Data for Timeline module
+     */
+    public function serviceGetTimelineData()
+    {
+    	$sModule = $this->_aModule['name'];
+        return array(
+            'handlers' => array(
+                array('group' => $sModule . '_object', 'type' => 'insert', 'alert_unit' => $sModule, 'alert_action' => 'added', 'module_name' => $sModule, 'module_method' => 'get_timeline_post', 'module_class' => 'Module', 'groupable' => 0, 'group_by' => ''),
+				array('group' => $sModule . '_completed', 'type' => 'insert', 'alert_unit' => $sModule, 'alert_action' => 'completed', 'module_name' => $sModule, 'module_method' => 'get_timeline_completed', 'module_class' => 'Module',  'groupable' => 0, 'group_by' => ''),
+				array('group' => $sModule . '_reopened', 'type' => 'insert', 'alert_unit' => $sModule, 'alert_action' => 'reopened', 'module_name' => $sModule, 'module_method' => 'get_timeline_reopened', 'module_class' => 'Module',  'groupable' => 0, 'group_by' => ''),
+                array('group' => $sModule . '_object', 'type' => 'update', 'alert_unit' => $sModule, 'alert_action' => 'edited'),
+                array('group' => $sModule . '_object', 'type' => 'delete', 'alert_unit' => $sModule, 'alert_action' => 'deleted'),
+            ),
+            'alerts' => array(
+                array('unit' => $sModule, 'action' => 'added'),
+				array('unit' => $sModule, 'action' => 'completed'),
+				array('unit' => $sModule, 'action' => 'reopened'),
+                array('unit' => $sModule, 'action' => 'edited'),
+                array('unit' => $sModule, 'action' => 'deleted'),
+            )
+        );
+    }
+	
     /**
      * Entry task for Timeline module
      */
@@ -176,11 +210,39 @@ class BxTasksModule extends BxBaseModTextModule implements iBxDolCalendarService
         $aResult = parent::serviceGetTimelinePost($aEvent, $aBrowseParams);
         if(empty($aResult) || !is_array($aResult) || empty($aResult['date']))
             return $aResult;
+        $aContentInfo = $this->_oDb->getContentInfoById($aEvent['object_id']);
+        if($aContentInfo[$CNF['FIELD_PUBLISHED']] > $aResult['date'])
+            $aResult['date'] = $aContentInfo[$CNF['FIELD_PUBLISHED']];
+        return $aResult;
+    }
+	
+	public function serviceGetTimelineCompleted($aEvent, $aBrowseParams = array())
+    {
+        $CNF = &$this->_oConfig->CNF;
 
+        $aResult = parent::serviceGetTimelinePost($aEvent, $aBrowseParams);
+		$aResult['sample_action'] = $aResult['content']['sample_action'] = _t('_bx_tasks_txt_action_completed');
+        if(empty($aResult) || !is_array($aResult) || empty($aResult['date']))
+            return $aResult;
+		
         $aContentInfo = $this->_oDb->getContentInfoById($aEvent['object_id']);
         if($aContentInfo[$CNF['FIELD_PUBLISHED']] > $aResult['date'])
             $aResult['date'] = $aContentInfo[$CNF['FIELD_PUBLISHED']];
+        return $aResult;
+    }
+	
+	public function serviceGetTimelineReopened($aEvent, $aBrowseParams = array())
+    {
+        $CNF = &$this->_oConfig->CNF;
 
+        $aResult = parent::serviceGetTimelinePost($aEvent, $aBrowseParams);
+		$aResult['sample_action'] = $aResult['content']['sample_action'] = _t('_bx_tasks_txt_action_reopened');
+        if(empty($aResult) || !is_array($aResult) || empty($aResult['date']))
+            return $aResult;
+		
+        $aContentInfo = $this->_oDb->getContentInfoById($aEvent['object_id']);
+        if($aContentInfo[$CNF['FIELD_PUBLISHED']] > $aResult['date'])
+            $aResult['date'] = $aContentInfo[$CNF['FIELD_PUBLISHED']];
         return $aResult;
     }
 

+ 2 - 0
modules/boonex/tasks/install/langs/en.xml

@@ -307,6 +307,8 @@
     <string name="_bx_tasks_txt_all_entries_by"><![CDATA[{0} tasks]]></string>
     <string name="_bx_tasks_txt_sample_single"><![CDATA[task]]></string>
     <string name="_bx_tasks_txt_sample_single_with_article"><![CDATA[a task]]></string>
+	<string name="_bx_tasks_txt_action_completed"><![CDATA[completed]]></string>
+	<string name="_bx_tasks_txt_action_reopened"><![CDATA[reopened]]></string>
     <string name="_bx_tasks_txt_sample_comment_single"><![CDATA[comment to task]]></string>
     <string name="_bx_tasks_txt_sample_vote_single"><![CDATA[vote to task]]></string>
     <string name="_bx_tasks_txt_sample_reaction_single"><![CDATA['{0}' reaction to task]]></string>