当前位置: 首页>>代码示例>>PHP>>正文


PHP base::validate方法代码示例

本文整理汇总了PHP中base::validate方法的典型用法代码示例。如果您正苦于以下问题:PHP base::validate方法的具体用法?PHP base::validate怎么用?PHP base::validate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在base的用法示例。


在下文中一共展示了base::validate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: validate

 /**
  * @return bool
  */
 public static function validate($params)
 {
     $dataformid = $params['dataformid'];
     $viewid = $params['viewid'];
     $df = \mod_dataform_dataform::instance($dataformid);
     $view = $df->view_manager->get_view_by_id($viewid);
     // Views manager can access any view in any mode.
     if (has_capability('mod/dataform:manageviews', $df->context)) {
         return true;
     }
     // Visible/Hidden view.
     $params['capabilities'] = array('mod/dataform:viewaccess');
     if ($view->visible and !parent::validate($params)) {
         return false;
     }
     // Disabled view.
     $params['capabilities'] = array('mod/dataform:viewaccessdisabled');
     if (!$view->visible and !parent::validate($params)) {
         return false;
     }
     // Early access.
     $params['capabilities'] = array('mod/dataform:viewaccessearly');
     if ($df->is_early() and !parent::validate($params)) {
         return false;
     }
     // Late access.
     $params['capabilities'] = array('mod/dataform:viewaccesslate');
     if ($df->is_past_due() and !parent::validate($params)) {
         return false;
     }
     return true;
 }
开发者ID:parksandwildlife,项目名称:learning,代码行数:35,代码来源:view_access.php

示例2: validate

 /**
  * Validates that current user can view the field content.
  *
  * @return bool
  */
 public static function validate($params)
 {
     global $USER;
     $dataformid = $params['dataformid'];
     $df = \mod_dataform_dataform::instance($dataformid);
     // Must have fieldid.
     if (empty($params['fieldid'])) {
         return false;
     }
     $field = $df->field_manager->get_field_by_id($params['fieldid']);
     $params['field'] = $field;
     // Must have entry.
     $entry = $params['entry'];
     // Get blank instance for new entries.
     if ($entry->id < 0) {
         $entry = \mod_dataform\pluginbase\dataformentry::blank_instance($df);
     }
     if ($field->visible != $field::VISIBLE_ALL) {
         // Entry managers can access any field.
         if (!($canmanageentries = has_capability('mod/dataform:manageentries', $field->df->context))) {
             if ($field->visible == $field::VISIBLE_NONE) {
                 return false;
             }
             $userid = !empty($entry->userid) ? $entry->userid : 0;
             $isentryowner = $USER->id == $userid;
             if ($field->visible == $field::VISIBLE_OWNER and !$isentryowner) {
                 return false;
             }
         }
     }
     // Early access.
     if ($df->is_early()) {
         $params['capabilities'] = array('mod/dataform:entryearlyview');
         if (!parent::validate($params)) {
             return false;
         }
     }
     // Late access.
     if ($df->is_past_due()) {
         $params['capabilities'] = array('mod/dataform:entrylateview');
         if (!parent::validate($params)) {
             return false;
         }
     }
     // Own entry.
     if (\mod_dataform\pluginbase\dataformentry::is_own($entry)) {
         $params['capabilities'] = array('mod/dataform:entryownview');
         return parent::validate($params);
     }
     // Group entry.
     if (\mod_dataform\pluginbase\dataformentry::is_grouped($entry)) {
         $params['capabilities'] = array('mod/dataform:entrygroupview');
         return parent::validate($params);
     }
     // Anonymous entry.
     if (\mod_dataform\pluginbase\dataformentry::is_anonymous($entry)) {
         $params['capabilities'] = array('mod/dataform:entryanonymousview');
         return parent::validate($params);
     }
     // Any entry.
     if (\mod_dataform\pluginbase\dataformentry::is_others($entry)) {
         $params['capabilities'] = array('mod/dataform:entryanyview');
         return parent::validate($params);
     }
     return false;
 }
开发者ID:parksandwildlife,项目名称:learning,代码行数:71,代码来源:field_view.php

示例3: validate

 /**
  * @return bool
  */
 public static function validate($params)
 {
     $dataformid = $params['dataformid'];
     $df = \mod_dataform_dataform::instance($dataformid);
     // Must have fieldid.
     if (empty($params['fieldid'])) {
         return false;
     }
     $field = $df->field_manager->get_field_by_id($params['fieldid']);
     $params['field'] = $field;
     if (!$field->editable and !has_capability('mod/dataform:manageentries', $field->df->context)) {
         return false;
     }
     // Must have entry.
     $entry = $params['entry'];
     // Get blank instance for new entries.
     if ($entry->id < 0) {
         $entry = \mod_dataform\pluginbase\dataformentry::blank_instance($df);
     }
     // Early access.
     if ($df->is_early()) {
         $params['capabilities'] = array('mod/dataform:entryearlyupdate');
         if (!parent::validate($params)) {
             return false;
         }
     }
     // Late access.
     if ($df->is_past_due()) {
         $params['capabilities'] = array('mod/dataform:entrylateupdate');
         if (!parent::validate($params)) {
             return false;
         }
     }
     // Own entry.
     if (\mod_dataform\pluginbase\dataformentry::is_own($entry)) {
         $params['capabilities'] = array('mod/dataform:entryownupdate');
         return parent::validate($params);
     }
     // Group entry.
     if (\mod_dataform\pluginbase\dataformentry::is_grouped($entry)) {
         $params['capabilities'] = array('mod/dataform:entrygroupupdate');
         return parent::validate($params);
     }
     // Anonymous entry.
     if (\mod_dataform\pluginbase\dataformentry::is_anonymous($entry)) {
         $params['capabilities'] = array('mod/dataform:entryanonymousupdate');
         return parent::validate($params);
     }
     // Any entry.
     if (\mod_dataform\pluginbase\dataformentry::is_others($entry)) {
         $params['capabilities'] = array('mod/dataform:entryanyupdate');
         return parent::validate($params);
     }
     return false;
 }
开发者ID:parksandwildlife,项目名称:learning,代码行数:58,代码来源:field_update.php


注:本文中的base::validate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。