Explorar o código

#1904 Classes module: minor changes

Alex Trofimov %!s(int64=6) %!d(string=hai) anos
pai
achega
c6424cb517

+ 3 - 2
modules/boonex/classes/classes/BxClssDb.php

@@ -36,14 +36,15 @@ class BxClssDb extends BxBaseModTextDb
 
     protected function _getNextPrevEntry ($iClassId, $sSorting = 'DESC', $sOp = '<=')
     {        
-        $aClass = $this->getRow("SELECT `c`.`id`, `c`.`order`, `m`.`order` as `order_module` FROM `" . $this->_oConfig->CNF['TABLE_ENTRIES'] . "` AS `c` INNER JOIN `" . $this->_oConfig->CNF['TABLE_MODULES'] . "` AS `m` ON (`m`.`id` = `c`.`module_id`) WHERE `c`.`id` = :class", array('class' => $iClassId));
+        $aClass = $this->getRow("SELECT `c`.`id`, `c`.`order`, `m`.`order` as `order_module`, `allow_view_to` as `context_profile_id` FROM `" . $this->_oConfig->CNF['TABLE_ENTRIES'] . "` AS `c` INNER JOIN `" . $this->_oConfig->CNF['TABLE_MODULES'] . "` AS `m` ON (`m`.`id` = `c`.`module_id`) WHERE `c`.`id` = :class", array('class' => $iClassId));
 
-        $sQuery = "SELECT `c`.`*`, `m`.`module_title` FROM `" . $this->_oConfig->CNF['TABLE_ENTRIES'] . "` AS `c` INNER JOIN `" . $this->_oConfig->CNF['TABLE_MODULES'] . "` AS `m` ON (`m`.`id` = `c`.`module_id`) WHERE `m`.`order`*1000000 + `c`.`order` $sOp :order_module*1000000 + :order AND `c`.`id` != :id ORDER BY `m`.`order`*1000000 + `c`.`order` $sSorting LIMIT 1";
+        $sQuery = "SELECT `c`.`*`, `m`.`module_title` FROM `" . $this->_oConfig->CNF['TABLE_ENTRIES'] . "` AS `c` INNER JOIN `" . $this->_oConfig->CNF['TABLE_MODULES'] . "` AS `m` ON (`m`.`id` = `c`.`module_id`) WHERE `m`.`order`*1000000 + `c`.`order` $sOp :order_module*1000000 + :order AND `c`.`id` != :id AND `allow_view_to` = :context_profile ORDER BY `m`.`order`*1000000 + `c`.`order` $sSorting LIMIT 1";
 
         $a = $this->getRow($sQuery, array(
             'order_module' => $aClass['order_module'], 
             'order' => $aClass['order'],
             'id' => $aClass['id'],
+            'context_profile' => $aClass['context_profile_id'],
         ));
 
         return $a;

+ 3 - 0
modules/boonex/classes/classes/BxClssFormEntry.php

@@ -209,6 +209,9 @@ class BxClssFormEntry extends BxBaseModTextFormEntry
         if (!$this->_bViewMode && !$this->_oProfileContext)
             return MsgBox(_t('_bx_classes_txt_err_cant_add_class_without_context'));
 
+        if (!$this->_bViewMode && isset($this->aInputs['module_id']) && !$this->aInputs['module_id']['values'])
+            return MsgBox(_t('_bx_classes_txt_err_cant_add_class_without_modules'));
+
         // TODO: check permission for adding to context
 
         return parent::getCode($bDynamicMode);

+ 4 - 3
modules/boonex/classes/classes/BxClssModule.php

@@ -265,7 +265,7 @@ class BxClssModule extends BxBaseModTextModule
         if ($mixedAvailability !== CHECK_ACTION_RESULT_ALLOWED) {
             if (null !== $iCounterNa) ++$iCounterNa;
             $sStatusClass = 'bx-classes-class-status-na';
-            $sTip = strip_tags($mixedAvailability);
+            $sTip = $mixedAvailability;
         }
         // check if class is completed
         elseif ($this->serviceIsClassCompleted($aClass['id'])) {
@@ -281,7 +281,7 @@ class BxClssModule extends BxBaseModTextModule
         $aContent = array (
             'title' => bx_process_output($aClass['title']),
             'url' => $this->serviceGetLink($aClass['id']),
-            'tip' => bx_html_attribute($sTip),
+            'tip' => $sTip,
             'date_created' => bx_time_js($aClass['added']),
             'start_date' => $aClass['start_date'] ? _t('_bx_classes_txt_start_x', bx_time_js($aClass['start_date'], BX_FORMAT_DATE_TIME)) : '',
             'end_date' => $aClass['end_date'] ? _t('_bx_classes_txt_due_x', bx_time_js($aClass['end_date'], BX_FORMAT_DATE_TIME)) : '',
@@ -362,10 +362,11 @@ class BxClssModule extends BxBaseModTextModule
 
         $this->_oTemplate->addCss('main.css');
         $this->_oTemplate->addJs('main.js');
+        $oForm->addCssJsUi();
 
         $bAdmin = isAdmin() || $this->serviceIsCourseAdmin($oContextProfile->id());
         return $this->_oTemplate->parseHtmlByName('classes_in_context.html', array(
-            'form' => $oForm->getCode(),
+            'form' => $aModules ? $oForm->getCode() : MsgBox(_t('_Empty')),
             'bx_if:edit_modules' => array(
                 'condition' => $bAdmin,
                 'content' => array(

+ 1 - 0
modules/boonex/classes/install/langs/en.xml

@@ -238,6 +238,7 @@
 
     <string name="_bx_classes_txt_err_cannot_perform_action"><![CDATA[Cannot perform action. Please report.]]></string>
     <string name="_bx_classes_txt_err_cant_add_class_without_context"><![CDATA[Class can be added into context only]]></string>
+    <string name="_bx_classes_txt_err_cant_add_class_without_modules"><![CDATA[Please create classes module first]]></string>
     <string name="_bx_classes_txt_err_not_avail_before_start_date"><![CDATA[Class will be available {0}]]></string>
     <string name="_bx_classes_txt_err_not_avail_before_prev_class_completed"><![CDATA[Class will be available after completing previous class - <a href="{0}">{1}</a>]]></string>
     <string name="_bx_classes_txt_err_modules_with_classes_cannot_be_deleted"><![CDATA[Modules with classes can't be deleted]]></string>

+ 3 - 2
modules/boonex/classes/template/classes_class_row.html

@@ -16,9 +16,10 @@
         </bx_if:avail>
         <bx_if:na>
             <i class="sys-icon ban col-red1 sys-colored"></i>
-            <b title="__tip__" class="bx-def-font-grayed">
+            <b class="bx-def-font-grayed">
                 __title__ 
-                <i class="sys-icon info-circle"></i>
+                <i class="sys-icon info-circle bx-classes-tip-icon" onclick="bx_alert($(this).next().html())"></i>
+                <template class="bx-classes-tip-html">__tip__</template>
             </b>
             <span class="bx-def-font-small bx-def-font-grayed">__date_created__</span>
             <span class="bx-def-font-small col-green1-dark">__start_date__</span>

+ 4 - 0
modules/boonex/classes/template/css/main.css

@@ -46,3 +46,7 @@
 .bx-classes-field-view-start-date {
     font-weight:bold;
 }
+
+.bx-classes-tip-icon {
+    cursor:pointer;
+}