Ver Fonte

#2688 enhancements

RomanL há 6 anos atrás
pai
commit
25a7b187d7

+ 1 - 1
modules/boonex/tasks/classes/BxTasksConfig.php

@@ -40,7 +40,7 @@ class BxTasksConfig extends BxBaseModTextConfig
             'FIELD_PUBLISHED' => 'published',
             'FIELD_TITLE' => 'title',
             'FIELD_TEXT' => 'text',
-            'FIELD_TEXT_ID' => '',
+            'FIELD_TEXT_ID' => 'post-text',
             'FIELD_CATEGORY' => 'cat',
             'FIELD_MULTICAT' => 'multicat',
             'FIELD_ALLOW_VIEW_TO' => 'allow_view_to',

+ 11 - 0
modules/boonex/tasks/classes/BxTasksDb.php

@@ -33,6 +33,17 @@ class BxTasksDb extends BxBaseModTextDb
         $sQuery = $this->prepare ("SELECT * FROM `" . $CNF['TABLE_LISTS'] . "` WHERE `id` = ?", $iId);
         return $this->getRow($sQuery);
     }
+    
+    public function deleteList ($iId = 0)
+    {
+        $CNF = &$this->_oConfig->CNF;
+
+        $sQuery = $this->prepare ("DELETE FROM `" . $CNF['TABLE_LISTS'] . "` WHERE `id` = ?", $iId);
+        $this->query($sQuery);
+        
+        $sQuery = $this->prepare ("DELETE FROM `" . $CNF['TABLE_ENTRIES'] . "` WHERE `" . $CNF['FIELD_TASKLIST'] . "` = ?", $iId);
+        $this->query($sQuery);
+    }
 	
 	public function getTasks ($iContextId = 0, $iListId = 0)
     {

+ 180 - 18
modules/boonex/tasks/classes/BxTasksModule.php

@@ -28,7 +28,6 @@ class BxTasksModule extends BxBaseModTextModule implements iBxDolCalendarService
     * Action methods
     */
 	
-	
     /**
      * Get possible recipients for start conversation form
      */
@@ -44,6 +43,9 @@ class BxTasksModule extends BxBaseModTextModule implements iBxDolCalendarService
           
     public function actionSetCompleted($iContentId, $iValue)
     {
+        if (!$this->isAllowManage($iContentId))
+            return;
+        
         $CNF = &$this->_oConfig->CNF;
 
         $this->_oDb->updateEntriesBy(array($CNF['FIELD_COMPLETED'] => $iValue), array($CNF['FIELD_ID'] => (int)$iContentId));
@@ -96,6 +98,9 @@ class BxTasksModule extends BxBaseModTextModule implements iBxDolCalendarService
 	
 	public function actionProcessTaskListForm($iContextId, $iId)
     {
+        if (!$this->isAllowAdd($iContextId))
+            return;
+        
 		$CNF = &$this->_oConfig->CNF;
 		$oForm = null;
 		$sPopupTitle = "";
@@ -143,9 +148,23 @@ class BxTasksModule extends BxBaseModTextModule implements iBxDolCalendarService
             return echoJson(array('form' => $sContent, 'form_id' => $oForm->getId()));;
         }
 	}
+    
+    public function actionDeleteTaskList($iId, $iContextId)
+    {
+        if (!$this->isAllowManageByContext($iContextId))
+            return;
+        
+        $this->_oDb->deleteList($iId);  
+        echoJson(array(
+            'context_id' => $iContextId,
+        ));
+    }
 	
 	public function actionProcessTaskForm($iContextId, $iListId)
     {
+        if (!$this->isAllowAdd($iContextId))
+            return;
+        
 		$CNF = &$this->_oConfig->CNF;
 		$oForm = BxDolForm::getObjectInstance($CNF['OBJECT_FORM_ENTRY'], $CNF['OBJECT_FORM_ENTRY_DISPLAY_ADD']);
 		
@@ -184,6 +203,9 @@ class BxTasksModule extends BxBaseModTextModule implements iBxDolCalendarService
         // check permissions
         $aSQLPart = array();
         $iContextId = (int)bx_get('context_id');
+        
+        if (!$this->isAllowView($iContextId))
+            return; 
 		
 		$oPrivacy = BxDolPrivacy::getObjectInstance($this->_oConfig->CNF['OBJECT_PRIVACY_VIEW']);
 		
@@ -347,12 +369,42 @@ class BxTasksModule extends BxBaseModTextModule implements iBxDolCalendarService
 
     public function serviceIsCompleted($iContentId)
     {
+        if (!$this->serviceIsAllowManage($iContentId))
+            return false;
+        
         $CNF = &$this->_oConfig->CNF;
 
         $aContentInfo = $this->_oDb->getContentInfoById($iContentId);
         return $aContentInfo[$CNF['FIELD_COMPLETED']] ? false: true;
     }
-	
+    
+    public function serviceIsUncompleted($iContentId)
+    {
+        if (!$this->serviceIsAllowManage($iContentId))
+            return false;
+        
+		$CNF = &$this->_oConfig->CNF;
+		$aContentInfo = $this->_oDb->getContentInfoById($iContentId);
+        return $aContentInfo[$CNF['FIELD_COMPLETED']] ? true : false;
+    }
+    
+    public function serviceIsAllowManage($iContentId)
+    {
+        if (!$this->isAllowManage($iContentId))
+            return false;
+        return true; 
+    }
+    
+    public function serviceIsAllowBadges($iContentId)
+    {
+        if (!$this->isAllowManage($iContentId))
+            return false;
+        
+        if (!$this->serviceIsBadgesAvaliable())
+            return false;
+        
+        return true; 
+    }
 	
 	public function serviceEntityAssignments($iContentId = 0, $bAsArray = false)
 	{
@@ -387,14 +439,6 @@ class BxTasksModule extends BxBaseModTextModule implements iBxDolCalendarService
         return $mixedResult;
     }
 	
-	public function serviceIsUncompleted($iContentId)
-    {
-		$CNF = &$this->_oConfig->CNF;
-		$aContentInfo = $this->_oDb->getContentInfoById($iContentId);
-        return $aContentInfo[$CNF['FIELD_COMPLETED']] ? true : false;
-    }
-
-	
     public function serviceCheckAllowedCommentsTask($iContentId, $sObjectComments) 
     {
         $CNF = &$this->_oConfig->CNF;
@@ -436,6 +480,9 @@ class BxTasksModule extends BxBaseModTextModule implements iBxDolCalendarService
      */
     public function serviceCalendar($aData = array(), $sTemplate = 'calendar.html')
     {
+        if (!$this->isAllowView($aData['context_id']))
+            return; 
+        
         $o = new BxTemplCalendar(array(
             'eventSources' => array (
                 bx_append_url_params(BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'calendar_data', $aData),
@@ -469,6 +516,14 @@ class BxTasksModule extends BxBaseModTextModule implements iBxDolCalendarService
 	
 	public function serviceBrowseTasks ($iContextId = 0, $aParams = array())
     {
+        if (!$this->isAllowView(-$iContextId))
+            return;  
+        
+        $oProfileContext = BxDolProfile::getInstance(-$iContextId);
+        $mixedResult = $oProfileContext->checkAllowedProfileView(-$iContextId);
+        if($mixedResult !== CHECK_ACTION_RESULT_ALLOWED)
+            return false;
+        
 		$CNF = &$this->_oConfig->CNF;
 		
 		$this->_oTemplate->addCssJs();
@@ -480,8 +535,11 @@ class BxTasksModule extends BxBaseModTextModule implements iBxDolCalendarService
 		$aFilterValues = array();
 		if (isset($_COOKIE[$CNF['COOKIE_SETTING_KEY']]))
 			$aFilterValues = json_decode($_COOKIE[$CNF['COOKIE_SETTING_KEY']], true);
-		
-		foreach($aLists as $aList) {
+
+        $bAllowAdd = $this->isAllowAdd(-$iContextId);
+        $bAllowManage = $this->isAllowManageByContext(-$iContextId);
+        
+        foreach($aLists as $aList) {
 			$aTasks = $this->_oDb->getTasks($iContextId, $aList['id']);
 			$aTasksVars = array();
 			foreach($aTasks as $aTask) {
@@ -495,15 +553,30 @@ class BxTasksModule extends BxBaseModTextModule implements iBxDolCalendarService
 					'id' => $aTask[$CNF['FIELD_ID']],
 					'title' => $aTask[$CNF['FIELD_TITLE']],
 					'created' => bx_time_js($aTask[$CNF['FIELD_ADDED']]),
-					'checked' => $aTask[$CNF['FIELD_COMPLETED']] == 1 ? 'checked' : '',
 					'class' => $aTask[$CNF['FIELD_COMPLETED']] == 1 ? 'completed' : 'uncompleted',
 					'due' => $aTask[$CNF['FIELD_DUEDATE']] > 0 ? bx_time_js($aTask[$CNF['FIELD_DUEDATE']]) : '',
 					'bx_repeat:members' => $aMembersVars,
 					'badges' => $this->serviceGetBadges($aTask[$CNF['FIELD_ID']], true),
 					'url' => BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $aTask[$CNF['FIELD_ID']]),
-					'object' => $this->_oConfig->getJsObject('tasks')
+					'object' => $this->_oConfig->getJsObject('tasks'),
+                    'bx_if:allow_manage' => array(
+				        'condition' => $bAllowManage,
+				        'content' => array(
+                            'id' => $aTask[$CNF['FIELD_ID']],
+                            'object' => $this->_oConfig->getJsObject('tasks'),
+                            'checked' => $aTask[$CNF['FIELD_COMPLETED']] == 1 ? 'checked' : '',
+                        )
+			        ),
+                    'bx_if:deny_manage' => array(
+				        'condition' => !$bAllowManage,
+				        'content' => array(
+                            'id' => $aTask[$CNF['FIELD_ID']],
+                            'checked' => $aTask[$CNF['FIELD_COMPLETED']] == 1 ? 'checked' : '',
+                        )
+			        ),
 				);
 			}
+            
 			$sClass = $sCompleted = $sAll = "";
 			if (isset($aFilterValues[$aList[$CNF['FIELD_ID']]])){
 				$sClass = $aFilterValues[$aList[$CNF['FIELD_ID']]];
@@ -512,8 +585,39 @@ class BxTasksModule extends BxBaseModTextModule implements iBxDolCalendarService
 				if ($sClass == 'all')
 					$sAll = 'selected';
 			}
+            
 			$aListsVars[] = array(
-				'title' => $aList[$CNF['FIELD_TITLE']],
+               'bx_if:allow_edit_list' => array(
+				    'condition' => $bAllowAdd,
+				    'content' => array(
+                        'title' => $aList[$CNF['FIELD_TITLE']],
+                        'context_id' => $iContextId,
+                        'list_id' => $aList[$CNF['FIELD_ID']],
+                        'object' => $this->_oConfig->getJsObject('tasks'),
+                    )
+			    ),
+               'bx_if:allow_add' => array(
+				    'condition' => $bAllowAdd,
+				    'content' => array(
+                        'context_id' => $iContextId,
+                        'list_id' => $aList[$CNF['FIELD_ID']],
+                        'object' => $this->_oConfig->getJsObject('tasks'),
+                    )
+			    ),
+                'bx_if:allow_delete_list' => array(
+				    'condition' => $bAllowManage,
+				    'content' => array(
+                        'context_id' => $iContextId,
+                        'list_id' => $aList[$CNF['FIELD_ID']],
+                        'object' => $this->_oConfig->getJsObject('tasks'),
+                    )
+			    ),
+                'bx_if:deny_edit_list' => array(
+				    'condition' => !$bAllowAdd,
+				    'content' => array(
+                        'title' => $aList[$CNF['FIELD_TITLE']],
+                    )
+			    ),
 				'id' => $aList['id'],
 				'bx_repeat:tasks' =>  $aTasksVars,
 				'context_id' => $iContextId,
@@ -527,8 +631,13 @@ class BxTasksModule extends BxBaseModTextModule implements iBxDolCalendarService
 		
 		$aVars = array(
 			'bx_repeat:task_lists' => $aListsVars,
-			'context_id' => $iContextId,
-			'object' => $this->_oConfig->getJsObject('tasks')
+			'bx_if:allow_add_list' => array(
+				'condition' => $bAllowAdd,
+				'content' => array(
+                    'context_id' => $iContextId,
+                    'object' => $this->_oConfig->getJsObject('tasks'),
+                )
+			),
 		);
 		
 		$this->_oTemplate->addJs(array(
@@ -537,9 +646,10 @@ class BxTasksModule extends BxBaseModTextModule implements iBxDolCalendarService
     		'jquery-ui/jquery.ui.autocomplete.min.js',
 			'jquery-ui/jquery.ui.core.min.js',
 			'tasks.js',
+            'modules/base/general/js/|forms.js'
     	));
 		
-		return $this->_oTemplate->getJsCode('tasks') . $this->_oTemplate->parseHtmlByName('browse_tasks.html', $aVars);
+		return $this->_oTemplate->getJsCode('tasks', array('t_confirm_block_deletion' => _t('_bx_tasks_confirm_tasklist_deletion'))) . $this->_oTemplate->parseHtmlByName('browse_tasks.html', $aVars);
     }
 	
     /**
@@ -564,6 +674,58 @@ class BxTasksModule extends BxBaseModTextModule implements iBxDolCalendarService
                     ));
         }
     }
+    
+    function isAllowView($iContextId)
+    {
+        $oProfileContext = BxDolProfile::getInstance($iContextId);
+        $mixedResult = $oProfileContext->checkAllowedProfileView($iContextId);
+        if($mixedResult !== CHECK_ACTION_RESULT_ALLOWED)
+            return false;
+        return true;
+    }
+    
+    function isAllowAdd($iContextId)
+    {
+        $oProfileContext = BxDolProfile::getInstance($iContextId);
+        $mixedResult = $oProfileContext->checkAllowedPostInProfile($iContextId);
+        if($mixedResult !== CHECK_ACTION_RESULT_ALLOWED)
+            return false;
+        return true;
+    }
+    
+    function isAllowManageByContext($iContextId)
+    {
+        if(isAdmin())
+            return true;
+      
+        $oProfileContext = BxDolProfile::getInstance($iContextId);
+        if(BxDolService::call($oProfileContext->getModule(), 'is_admin', array($iContextId)))
+            return true;
+    }
+    
+    function isAllowManage($iContentId)
+    {
+        $CNF = &$this->_oConfig->CNF;
+        
+        $aContentInfo = $this->_oDb->getContentInfoById($iContentId);
+        $bRv = $this->isAllowManageByContext(-$aContentInfo[$CNF['FIELD_ALLOW_VIEW_TO']]);
+        if ($bRv)
+            return $bRv;
+        
+        if ($aContentInfo[$CNF['FIELD_AUTHOR']] == bx_get_logged_profile_id())
+            return true;
+       
+        $oConnection = BxDolConnection::getObjectInstance($CNF['OBJECT_CONNECTION']);
+        if($oConnection) {
+            $aProfileIds = $oConnection->getConnectedContent($iContentId);
+            if(!empty($aProfileIds) && is_array($aProfileIds)){
+                if (in_array(bx_get_logged_profile_id(), $aProfileIds))
+                    return true;
+            }
+        }
+
+        return false;
+    }
 }
 
 /** @} */

+ 7 - 0
modules/boonex/tasks/classes/BxTasksTemplate.php

@@ -29,6 +29,13 @@ class BxTasksTemplate extends BxBaseModTextTemplate
 
         return array($sPhotoGallery, $sPhotoGallery);
     }
+    
+    public function entryText ($aData, $sTemplateName = 'entry-text.html')
+    {
+        $aVars = $this->getTmplVarsText($aData);
+
+        return $this->parseHtmlByName($sTemplateName, $aVars);
+    }
 }
 
 /** @} */

+ 3 - 1
modules/boonex/tasks/install/langs/en.xml

@@ -326,8 +326,10 @@
     <string name="_bx_tasks_txt_filter_completed"><![CDATA[Completed Tasks]]></string>
     <string name="_bx_tasks_txt_filter_uncompleted"><![CDATA[Uncompleted Tasks]]></string>
     <string name="_bx_tasks_txt_err_cannot_perform_action"><![CDATA[Cannot perform action. Please report.]]></string>
+    <string name="_bx_tasks_confirm_tasklist_deletion"><![CDATA[You will delete all tasks that are contained in this tasklist. Are you sure?]]></string>
+  
 
-    <!-- Notifications -->
+  <!-- Notifications -->
     <string name="_bx_tasks_alert_action_completed_personal"><![CDATA[Complete task]]></string>
     <string name="_bx_tasks_alert_action_completed_follow_member"><![CDATA[Complete task]]></string>
     <string name="_bx_tasks_alert_action_completed_follow_context"><![CDATA[Complete task]]></string>

+ 7 - 9
modules/boonex/tasks/install/sql/enable.sql

@@ -55,7 +55,7 @@ INSERT INTO `sys_objects_page`(`object`, `title_system`, `title`, `module`, `lay
 INSERT INTO `sys_pages_blocks`(`object`, `cell_id`, `module`, `title_system`, `title`, `designbox_id`, `visible_for_levels`, `type`, `content`, `deletable`, `copyable`, `active`, `order`) VALUES 
 ('bx_tasks_view_entry', 2, 'bx_tasks', '', '_bx_tasks_page_block_title_entry_text', 13, 2147483647, 'service', 'a:2:{s:6:\"module\";s:8:\"bx_tasks\";s:6:\"method\";s:17:\"entity_text_block\";}', 0, 0, 1, 2),
 ('bx_tasks_view_entry', 2, 'bx_tasks', '', '_bx_tasks_page_block_title_entry_author', 13, 2147483647, 'service', 'a:2:{s:6:\"module\";s:8:\"bx_tasks\";s:6:\"method\";s:13:\"entity_author\";}', 0, 0, 1, 1),
-('bx_tasks_view_entry', 2, 'bx_tasks', '', '_bx_tasks_page_block_title_entry_assignments', 13, 2147483647, 'service', 'a:2:{s:6:\"module\";s:8:\"bx_tasks\";s:6:\"method\";s:18:\"entity_assignments\";}', 0, 0, 1, 2),
+('bx_tasks_view_entry', 2, 'bx_tasks', '', '_bx_tasks_page_block_title_entry_assignments', 11, 2147483647, 'service', 'a:2:{s:6:\"module\";s:8:\"bx_tasks\";s:6:\"method\";s:18:\"entity_assignments\";}', 0, 0, 1, 2),
 ('bx_tasks_view_entry', 3, 'bx_tasks', '_bx_tasks_page_block_title_sys_entry_context', '_bx_tasks_page_block_title_entry_context', 13, 2147483647, 'service', 'a:2:{s:6:\"module\";s:8:\"bx_tasks\";s:6:\"method\";s:14:\"entity_context\";}', 0, 0, 1, 1),
 ('bx_tasks_view_entry', 3, 'bx_tasks', '', '_bx_tasks_page_block_title_entry_info', 11, 2147483647, 'service', 'a:2:{s:6:\"module\";s:8:\"bx_tasks\";s:6:\"method\";s:11:\"entity_info\";}', 0, 0, 1, 2),
 ('bx_tasks_view_entry', 2, 'bx_tasks', '', '_bx_tasks_page_block_title_entry_all_actions', 13, 2147483647, 'service', 'a:2:{s:6:\"module\";s:8:\"bx_tasks\";s:6:\"method\";s:18:\"entity_all_actions\";}', 0, 0, 1, 3),
@@ -107,9 +107,9 @@ INSERT INTO `sys_objects_menu`(`object`, `title`, `set_name`, `module`, `templat
 INSERT INTO `sys_menu_sets`(`set_name`, `module`, `title`, `deletable`) VALUES 
 ('bx_tasks_view', 'bx_tasks', '_bx_tasks_menu_set_title_view_entry', 0);
 
-INSERT INTO `sys_menu_items`(`set_name`, `module`, `name`, `title_system`, `title`, `link`, `onclick`, `target`, `icon`, `submenu_object`, `visible_for_levels`, `active`, `copyable`, `order`) VALUES 
-('bx_tasks_view', 'bx_tasks', 'edit-task', '_bx_tasks_menu_item_title_system_edit_entry', '_bx_tasks_menu_item_title_edit_entry', 'page.php?i=edit-task&id={content_id}', '', '', 'pencil-alt', '', 2147483647, 1, 0, 1),
-('bx_tasks_view', 'bx_tasks', 'delete-task', '_bx_tasks_menu_item_title_system_delete_entry', '_bx_tasks_menu_item_title_delete_entry', 'page.php?i=delete-task&id={content_id}', '', '', 'remove', '', 2147483647, 1, 0, 2);
+INSERT INTO `sys_menu_items`(`set_name`, `module`, `name`, `title_system`, `title`, `link`, `onclick`, `target`, `icon`, `submenu_object`, `visible_for_levels`, `visibility_custom`, `active`, `copyable`, `order`) VALUES 
+('bx_tasks_view', 'bx_tasks', 'edit-task', '_bx_tasks_menu_item_title_system_edit_entry', '_bx_tasks_menu_item_title_edit_entry', 'page.php?i=edit-task&id={content_id}', '', '', 'pencil-alt', '', 2147483647, 'a:3:{s:6:"module";s:8:"bx_tasks";s:6:"method";s:15:"is_allow_manage";s:6:"params";a:1:{i:0;s:12:"{content_id}";}}', 1, 0, 1),
+('bx_tasks_view', 'bx_tasks', 'delete-task', '_bx_tasks_menu_item_title_system_delete_entry', '_bx_tasks_menu_item_title_delete_entry', 'page.php?i=delete-task&id={content_id}', '', '', 'remove', '', 2147483647, 'a:3:{s:6:"module";s:8:"bx_tasks";s:6:"method";s:15:"is_allow_manage";s:6:"params";a:1:{i:0;s:12:"{content_id}";}}', 1, 0, 2);
 
 
 -- MENU: all actions menu for view entry 
@@ -121,18 +121,16 @@ INSERT INTO `sys_menu_sets`(`set_name`, `module`, `title`, `deletable`) VALUES
 ('bx_tasks_view_actions', 'bx_tasks', '_sys_menu_set_title_view_actions', 0);
 
 INSERT INTO `sys_menu_items`(`set_name`, `module`, `name`, `title_system`, `title`, `link`, `onclick`, `target`, `icon`, `addon`, `submenu_object`, `submenu_popup`, `visible_for_levels`, `visibility_custom`, `active`, `copyable`, `order`) VALUES 
-('bx_tasks_view_actions', 'bx_tasks', 'edit-task', '_bx_tasks_menu_item_title_system_edit_entry', '', '', '', '', '', '', '', 0, 2147483647, '', 1, 0, 10),
-('bx_tasks_view_actions', 'bx_tasks', 'delete-task', '_bx_tasks_menu_item_title_system_delete_entry', '', '', '', '', '', '', '', 0, 2147483647, '', 1, 0, 20),
+('bx_tasks_view_actions', 'bx_tasks', 'edit-task', '_bx_tasks_menu_item_title_system_edit_entry', '', '', '', '', '', '', '', 0, 2147483647, 'a:3:{s:6:"module";s:8:"bx_tasks";s:6:"method";s:15:"is_allow_manage";s:6:"params";a:1:{i:0;s:12:"{content_id}";}}', 1, 0, 10),
+('bx_tasks_view_actions', 'bx_tasks', 'delete-task', '_bx_tasks_menu_item_title_system_delete_entry', '', '', '', '', '', '', '', 0, 2147483647, 'a:3:{s:6:"module";s:8:"bx_tasks";s:6:"method";s:15:"is_allow_manage";s:6:"params";a:1:{i:0;s:12:"{content_id}";}}', 1, 0, 20),
 ('bx_tasks_view_actions', 'bx_tasks', 'set-completed', '_bx_tasks_menu_item_title_system_set_completed', '_bx_tasks_menu_item_title_set_completed', 'javascript:void(0)', 'javascript:{js_object}.setCompletedByMenu({content_id}, 1, this);', '', 'check', '', '', 0, 2147483647, 'a:3:{s:6:"module";s:8:"bx_tasks";s:6:"method";s:12:"is_completed";s:6:"params";a:1:{i:0;s:12:"{content_id}";}}', 1, 0, 30),
 ('bx_tasks_view_actions', 'bx_tasks', 'set-uncompleted', '_bx_tasks_menu_item_title_system_set_uncompleted', '_bx_tasks_menu_item_title_set_uncompleted', 'javascript:void(0)', 'javascript:{js_object}.setCompletedByMenu({content_id}, 0, this);', '', 'circle', '', '', 0, 2147483647, 'a:3:{s:6:"module";s:8:"bx_tasks";s:6:"method";s:14:"is_uncompleted";s:6:"params";a:1:{i:0;s:12:"{content_id}";}}', 1, 0, 35),
-('bx_tasks_view_actions', 'bx_tasks', 'set-badges', '_sys_menu_item_title_system_set_badges', '_sys_menu_item_title_set_badges', 'javascript:void(0)', 'bx_menu_popup(''sys_set_badges'', window, {}, {module: ''bx_tasks'', content_id: {content_id}});', '', 'check-circle', '', '', 0, 2147483647, 'a:2:{s:6:"module";s:8:"bx_tasks";s:6:"method";s:19:"is_badges_avaliable";}', 1, 0, 40),
+('bx_tasks_view_actions', 'bx_tasks', 'set-badges', '_sys_menu_item_title_system_set_badges', '_sys_menu_item_title_set_badges', 'javascript:void(0)', 'bx_menu_popup(''sys_set_badges'', window, {}, {module: ''bx_tasks'', content_id: {content_id}});', '', 'check-circle', '', '', 0, 2147483647, 'a:3:{s:6:"module";s:8:"bx_tasks";s:6:"method";s:15:"is_allow_badges";s:6:"params";a:1:{i:0;s:12:"{content_id}";}}', 1, 0, 40),
 ('bx_tasks_view_actions', 'bx_tasks', 'comment', '_sys_menu_item_title_system_va_comment', '', '', '', '', '', '', '', 0, 2147483647, '', 0, 0, 200),
 ('bx_tasks_view_actions', 'bx_tasks', 'view', '_sys_menu_item_title_system_va_view', '', '', '', '', '', '', '', 0, 2147483647, '', 1, 0, 210),
 ('bx_tasks_view_actions', 'bx_tasks', 'vote', '_sys_menu_item_title_system_va_vote', '', '', '', '', '', '', '', 0, 2147483647, '', 0, 0, 220),
 ('bx_tasks_view_actions', 'bx_tasks', 'reaction', '_sys_menu_item_title_system_va_reaction', '', '', '', '', '', '', '', 0, 2147483647, '', 1, 0, 225),
 ('bx_tasks_view_actions', 'bx_tasks', 'score', '_sys_menu_item_title_system_va_score', '', '', '', '', '', '', '', 0, 2147483647, '', 1, 0, 230),
-('bx_tasks_view_actions', 'bx_tasks', 'favorite', '_sys_menu_item_title_system_va_favorite', '', '', '', '', '', '', '', 0, 2147483647, '', 1, 0, 240),
-('bx_tasks_view_actions', 'bx_tasks', 'feature', '_sys_menu_item_title_system_va_feature', '', '', '', '', '', '', '', 0, 2147483647, '', 1, 0, 250),
 ('bx_tasks_view_actions', 'bx_tasks', 'repost', '_sys_menu_item_title_system_va_repost', '', '', '', '', '', '', '', 0, 2147483647, '', 1, 0, 260),
 ('bx_tasks_view_actions', 'bx_tasks', 'report', '_sys_menu_item_title_system_va_report', '', '', '', '', '', '', '', 0, 2147483647, '', 1, 0, 270),
 ('bx_tasks_view_actions', 'bx_tasks', 'notes', '_sys_menu_item_title_system_va_notes', '_sys_menu_item_title_va_notes', 'javascript:void(0)', 'javascript:bx_get_notes(this,  ''{module_uri}'', {content_id});', '', 'exclamation-triangle', '', '', 0, 2147483647, '', 1, 0, 280),

+ 1 - 2
modules/boonex/tasks/install/sql/install.sql

@@ -411,8 +411,7 @@ INSERT INTO `sys_form_display_inputs`(`display_name`, `input_name`, `visible_for
 ('bx_tasks_entry_view', 'cat', 2147483647, 1, 1),
 ('bx_tasks_entry_view', 'added', 2147483647, 1, 2),
 ('bx_tasks_entry_view', 'changed', 2147483647, 1, 3),
-('bx_tasks_entry_view', 'due_date', 192, 1, 4),
-('bx_tasks_entry_view', 'published', 192, 1, 5);
+('bx_tasks_entry_view', 'due_date', 192, 1, 4);
 
 
 -- FORMS: entry (tasklist)

+ 14 - 7
modules/boonex/tasks/js/tasks.js

@@ -8,8 +8,7 @@
  */
 
 function BxTasksView(oOptions) {
-    this._sActionsUri = oOptions.sActionUri;
-	
+    this._oOptions = oOptions
     var $this = this;
     $(document).ready(function () {
         $this.init();
@@ -35,22 +34,31 @@ BxTasksView.prototype.setCompletedByMenu = function (iId, iValue, oObj) {
 
 BxTasksView.prototype._setCompleted = function (iId, iValue) {
 	var $this = this;
-	$.getJSON($this._sActionsUri + 'set_completed/' + iId + '/' + iValue + '/', {}, function () {});
+	$.getJSON($this._oOptions.sActionUri + 'set_completed/' + iId + '/' + iValue + '/', {}, function () { });
 }
 	
 BxTasksView.prototype.processTaskList = function (iContextId, iId, obj) {
     var $this = this;
 	$(window).dolPopupAjax({
-        url: $this._sActionsUri + 'process_task_list_form/' + iContextId + '/' + iId + '/' ,
+	    url: $this._oOptions.sActionUri + 'process_task_list_form/' + iContextId + '/' + iId + '/',
         closeOnOuterClick: false,
 		removeOnClose: true
     });   
 }
+
+BxTasksView.prototype.deleteTaskList = function (iId, iContextId, obj) {
+    var $this = this;
+    bx_confirm($this._oOptions.t_confirm_block_deletion, function () {
+        $.getJSON($this._oOptions.sActionUri + 'delete_task_list/' + iId + '/' + iContextId + '/', {}, function (oData) {
+            $this.reloadData(oData, iContextId)
+        });
+    });
+}
 	
 BxTasksView.prototype.processTask = function (iContextId, iListId, obj) {
     var $this = this;
 	$(window).dolPopupAjax({
-        url: $this._sActionsUri + 'process_task_form/' + iContextId + '/' + iListId + '/' ,
+	    url: $this._oOptions.sActionUri + 'process_task_form/' + iContextId + '/' + iListId + '/',
         closeOnOuterClick: false,
         removeOnClose: true
     });   
@@ -72,7 +80,6 @@ BxTasksView.prototype.setFilter = function (iListId, object) {
 	if (val)
 		$('#bx-tasks-tasklist-' + iListId).addClass('bx-tasks-tasklist-filter-' + val);
   	
-	$.getJSON(this._sActionsUri + 'setFilterValue/' + iListId + '/' + val + '/' , function (oData) {
-	});
+	$.getJSON($this._oOptions.sActionUri + 'setFilterValue/' + iListId + '/' + val + '/', function (oData) {});
 }
 

+ 56 - 35
modules/boonex/tasks/template/browse_tasks.html

@@ -1,37 +1,58 @@
-<a class="bx-btn bx-btn-small bx-def-margin-sec-right bx-tasks-tasklist-add" href="javascript:void(0);" onClick="__object__.processTaskList(__context_id__, 0, this)"><bx_text:_bx_tasks_txt_new_task_list /></a>
+<bx_if:allow_add_list>
+    <a class="bx-btn bx-btn-small bx-def-margin-sec-right bx-tasks-tasklist-add" href="javascript:void(0);" onclick="__object__.processTaskList(__context_id__, 0, this)">
+        <bx_text:_bx_tasks_txt_new_task_list />
+    </a>
+</bx_if:allow_add_list>
 <div class="bx-def-padding-top" style="clear: both">
-	<bx_repeat:task_lists>
-		<div class="bx-def-margin-top bx-def-padding-bottom bx-tasks-tasklist bx-tasks-tasklist-filter-__class__" id="bx-tasks-tasklist-__list_id__">
-		<div class="bx-def-padding-sec bx-def-color-bg-hl">
-			<span class="bx-tasks-tasklist-title"><a href="javascript:void(0);" onClick="__object__.processTaskList(__context_id__, __list_id__, this)" title="__title__">__title__</a></span>
-			<div class="bx-tasks-tasklist-actions">
-				<select class="bx-btn bx-btn-small bx-def-margin-sec-right" onChange="__object__.setFilter(__list_id__, this)">
-					<option value=""><bx_text:_bx_tasks_txt_filter_uncompleted /></option>
-					<option __all__ value="all"><bx_text:_bx_tasks_txt_filter_all /></option>
-					<option __completed__ value="completed"><bx_text:_bx_tasks_txt_filter_completed /></option>
-				</select>
-				<a class="bx-btn bx-btn-small" href="javascript:void(0);" onClick="__object__.processTask(__context_id__, __list_id__, this)"><bx_text:_bx_tasks_txt_new_task /></a> 
-			</div>
-			</div>
-		<bx_repeat:tasks>
-			<div class="bx-def-padding-sec  bx-def-border-bottom  bx-tasks-task bx-tasks-task-__class__">
-				<div class="bx-tasks-task-checkbox bx-def-padding-sec-right">
-					<input id="checkbox__id__" type="checkbox" __checked__ class="promoted-input-checkbox" onClick="__object__.setCompleted(__id__, this)"/>
-					<label for="checkbox__id__"></label>
-				</div>
+    <bx_repeat:task_lists>
+        <div class="bx-def-margin-top bx-def-padding-bottom bx-tasks-tasklist bx-tasks-tasklist-filter-__class__" id="bx-tasks-tasklist-__list_id__">
+            <div class="bx-def-padding-sec bx-def-color-bg-hl">
+                <span class="bx-tasks-tasklist-title">
+                    <bx_if:allow_edit_list>
+                        <a href="javascript:void(0);" onclick="__object__.processTaskList(__context_id__, __list_id__, this)" title="__title__">__title__</a>
+                    </bx_if:allow_edit_list>
+                    <bx_if:deny_edit_list>
+                        __title__
+                    </bx_if:deny_edit_list>
+                </span>
+                <div class="bx-tasks-tasklist-actions">
+                    <select class="bx-btn bx-btn-small bx-def-margin-sec-right" onchange="__object__.setFilter(__list_id__, this)">
+                        <option value=""><bx_text:_bx_tasks_txt_filter_uncompleted /></option>
+                        <option __all__ value="all"><bx_text:_bx_tasks_txt_filter_all /></option>
+                        <option __completed__ value="completed"><bx_text:_bx_tasks_txt_filter_completed /></option>
+                    </select>
+                    <bx_if:allow_add>
+                        <a class="bx-btn bx-btn-small bx-def-margin-sec-right" href="javascript:void(0);" onclick="__object__.processTask(__context_id__, __list_id__, this)"><bx_text:_bx_tasks_txt_new_task /></a>
+                    </bx_if:allow_add>
+                    <bx_if:allow_delete_list>
+                        <a class="bx-btn bx-btn-small" href="javascript:void(0);" onclick="__object__.deleteTaskList(__list_id__, __context_id__, this)"><i class="sys-icon remove"></i></a>
+                    </bx_if:allow_delete_list>
+                </div>
+            </div>
+            <bx_repeat:tasks>
+                <div class="bx-def-padding-sec  bx-def-border-bottom  bx-tasks-task bx-tasks-task-__class__">
+                    <div class="bx-tasks-task-checkbox bx-def-padding-sec-right">
+                        <bx_if:allow_manage>
+                            <input id="checkbox__id__" type="checkbox" __checked__ class="promoted-input-checkbox" onclick="__object__.setCompleted(__id__, this)">
+                        </bx_if:allow_manage>
+                        <bx_if:deny_manage>
+                            <input id="checkbox__id__" type="checkbox" __checked__ class="promoted-input-checkbox" disabled>
+                        </bx_if:deny_manage>
+                        <label for="checkbox__id__"></label>
+                    </div>
 
-				<a href="__url__" class="bx-def-padding-sec-right bx-tasks-task-name" title="__title__">__title__</a>
-				
-				<span class="bx-def-font-grayed bx-def-padding-sec-right">__created__</span>
-				<span class="bx-task-due-date bx-def-padding-sec-right">__due__</span> 
-				__badges__
-				<div class="bx-tasks-members">
-					<bx_repeat:members>
-						__info__
-					</bx_repeat:members>
-				</div>
-			</div>
-		</bx_repeat:tasks>
-		</div>
-	</bx_repeat:task_lists>
-</div>
+                    <a href="__url__" class="bx-def-padding-sec-right bx-tasks-task-name" title="__title__">__title__</a>
+
+                    <span class="bx-def-font-small bx-def-font-grayed bx-def-padding-sec-right">__created__</span>
+                    <span class="bx-def-font-small bx-task-due-date bx-def-padding-sec-right">__due__</span>
+                    __badges__
+                    <div class="bx-tasks-members">
+                        <bx_repeat:members>
+                            __info__
+                        </bx_repeat:members>
+                    </div>
+                </div>
+            </bx_repeat:tasks>
+        </div>
+    </bx_repeat:task_lists>
+</div>