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


PHP Dataface_Table::getPermissions方法代码示例

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


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

示例1: loadFromTable

 /**
  * @brief Loads the values for a particular field in a particular table.
  *
  * This method is delegated to by handle() for cleanliness purposes.
  *
  * @param Dataface_Table $table The table where the depselect field resides.
  * @param array &$field The field definition of the depselect field.
  * @param array $query The current GET parameters.
  * 
  */
 private function loadFromTable(Dataface_Table $table, &$field, $query)
 {
     try {
         $perms = $table->getPermissions(array('field' => $field['name']));
         if (!@$perms['edit'] and !@$perms['new']) {
             // The user doesn't have permission to edit the column... so we
             // need to cut off access right now!!!
             error_log("Insufficient permissions to access field {$field['name']} by current user.");
             throw new Exception("Failed to get options for field {$filed['name']} because you don't have view permission for this field.", 401);
         }
         if (!@$field['widget']['table']) {
             error_log("widget:table not defined for field " . $field['name'] . " of table " . $table->tablename . ".");
             throw new Exception(self::errorMessage($fieldname), 500);
         }
         $targetTable = Dataface_Table::loadTable($field['widget']['table']);
         $filters = array();
         if (@$field['widget']['filters'] and is_array($field['widget']['filters'])) {
             foreach ($field['widget']['filters'] as $key => $val) {
                 if (isset($query[$key])) {
                     $filters[$key] = $query[$key];
                 } else {
                     if (strpos($val, '$') === 0) {
                         $filters[$key] = '=';
                     } else {
                         $filters[$key] = $val;
                     }
                 }
             }
         }
         $limit = 250;
         if (@$field['widget']['limit']) {
             $limit = intval($field['widget']['limit']);
         }
         $filters['-limit'] = $limit;
         $records = df_get_records_array($field['widget']['table'], $filters);
         //if ( count($filters) > 1 ){
         //	echo "Num records found: ".count($records);
         //	print_r($filters);
         //}
         $keyCol = null;
         $labelCol = null;
         $multiLabel = null;
         if (@$field['widget']['keycol']) {
             $keyCol = $field['widget']['keycol'];
         } else {
             foreach ($targetTable->keys() as $k => $v) {
                 $keyCol = $k;
                 break;
             }
         }
         if (@$field['widget']['labelcol']) {
             $labelCol = $field['widget']['labelcol'];
         } else {
             if (@$field['widget']['multilabelformat']) {
                 $multiLabel = $field['widget']['multilabelformat'];
                 $params = explode('"', $multiLabel);
                 // The first array elements are empty due to the first '"' and ','.
                 $format = $params[1];
                 $colums = explode(',', $params[2]);
                 array_shift($colums);
             }
         }
         $out = array();
         foreach ($records as $r) {
             if (@$field['widget']['ignore_permissions']) {
                 $r->secureDisplay = false;
             } else {
                 //if ( !$r->checkPermission('view') ) continue;
                 if (!$r->checkPermission('view', array('field' => $keyCol))) {
                     continue;
                 }
                 if ($labelCol and !$r->checkPermission('view', array('field' => $labelCol))) {
                     continue;
                 }
             }
             if ($labelCol) {
                 $temp = array($r->val($keyCol) => $r->display($labelCol));
             } else {
                 if ($multiLabel) {
                     $values = array();
                     foreach ($colums as $field) {
                         $values[] = $r->display(trim($field));
                     }
                     $temp = array($r->val($keyCol) => vsprintf($format, $values));
                 } else {
                     $temp = array($r->val($keyCol) => $r->getTitle());
                 }
             }
             $out[] = $temp;
         }
//.........这里部分代码省略.........
开发者ID:shannah,项目名称:xataface-module-depselect,代码行数:101,代码来源:depselect_load.php


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