當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。