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


PHP PodsForm::permission方法代码示例

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


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

示例1: input

 /**
  * Customize output of the form field
  *
  * @param string $name
  * @param mixed $value
  * @param array $options
  * @param array $pod
  * @param int $id
  *
  * @since 2.0
  */
 public function input($name, $value = null, $options = null, $pod = null, $id = null)
 {
     $options = (array) $options;
     $form_field_type = PodsForm::$field_type;
     if (is_array($value)) {
         $value = !empty($value);
     }
     $field_type = 'checkbox';
     if ('radio' == pods_v(self::$type . '_format_type', $options)) {
         $field_type = 'radio';
     } elseif ('dropdown' == pods_v(self::$type . '_format_type', $options)) {
         $field_type = 'select';
     }
     if (isset($options['name']) && false === PodsForm::permission(self::$type, $options['name'], $options, null, $pod, $id)) {
         if (pods_v('read_only', $options, false)) {
             $options['readonly'] = true;
         } else {
             return;
         }
     } elseif (!pods_has_permissions($options) && pods_v('read_only', $options, false)) {
         $options['readonly'] = true;
     }
     if (1 === $value || '1' === $value || true === $value) {
         $value = 1;
     } else {
         $value = 0;
     }
     pods_view(PODS_DIR . 'ui/fields/' . $field_type . '.php', compact(array_keys(get_defined_vars())));
 }
开发者ID:dylansmithing,项目名称:leader-of-rock-wordpress,代码行数:40,代码来源:boolean.php

示例2: input

 /**
  * Customize output of the form field
  *
  * @param string $name
  * @param mixed $value
  * @param array $options
  * @param array $pod
  * @param int $id
  *
  * @since 2.0
  */
 public function input($name, $value = null, $options = null, $pod = null, $id = null)
 {
     $options = (array) $options;
     $form_field_type = PodsForm::$field_type;
     if (is_array($value)) {
         $value = implode(' ', $value);
     }
     $field_type = 'email';
     if (isset($options['name']) && false === PodsForm::permission(self::$type, $options['name'], $options, null, $pod, $id)) {
         if (pods_var('read_only', $options, false)) {
             $options['readonly'] = true;
             $field_type = 'text';
         } else {
             return;
         }
     } elseif (!pods_has_permissions($options) && pods_var('read_only', $options, false)) {
         $options['readonly'] = true;
         $field_type = 'text';
     }
     pods_view(PODS_DIR . 'ui/fields/' . $field_type . '.php', compact(array_keys(get_defined_vars())));
 }
开发者ID:Ingenex,项目名称:redesign,代码行数:32,代码来源:email.php

示例3: view

    /**
     * @return bool|mixed
     * @since 2.3.10
     */
    public function view()
    {
        if (false !== $this->callback_action('view')) {
            return null;
        }
        if (empty($this->row)) {
            $this->get_row();
        }
        if (empty($this->row)) {
            return $this->error(sprintf(__('<strong>Error:</strong> %s not found.', 'pods'), $this->item));
        }
        $pod =& $this->pod;
        $obj =& $this;
        $fields = array();
        if (isset($this->fields[$this->action])) {
            $fields = $this->fields[$this->action];
        }
        if (is_object($this->pod)) {
            $object_fields = (array) pods_var_raw('object_fields', $this->pod->pod_data, array(), null, true);
            $object_field_objects = array('post_type', 'taxonomy', 'media', 'user', 'comment');
            if (empty($object_fields) && in_array($this->pod->pod_data['type'], $object_field_objects)) {
                $object_fields = $this->pod->api->get_wp_object_fields($this->pod->pod_data['type'], $this->pod->pod_data);
            }
            if (empty($fields)) {
                // Add core object fields if $fields is empty
                $fields = array_merge($object_fields, $this->pod->fields);
            }
        }
        $view_fields = $fields;
        // Temporary
        $fields = array();
        foreach ($view_fields as $k => $field) {
            $name = $k;
            $defaults = array('name' => $name, 'type' => 'text', 'options' => 'text');
            if (!is_array($field)) {
                $name = $field;
                $field = array('name' => $name);
            }
            $field = array_merge($defaults, $field);
            $field['name'] = trim($field['name']);
            $value = pods_var_raw('default', $field);
            if (empty($field['name'])) {
                $field['name'] = trim($name);
            }
            if (isset($object_fields[$field['name']])) {
                $field = array_merge($field, $object_fields[$field['name']]);
            } elseif (isset($this->pod->fields[$field['name']])) {
                $field = array_merge($this->pod->fields[$field['name']], $field);
            }
            if (pods_v('hidden', $field, false, null, true) || 'hidden' == $field['type']) {
                continue;
            } elseif (!PodsForm::permission($field['type'], $field['name'], $field['options'], $fields, $pod, $pod->id())) {
                continue;
            }
            $fields[$field['name']] = $field;
            if (empty($this->id) && null !== $value) {
                $this->pod->row_override[$field['name']] = $value;
            }
        }
        unset($view_fields);
        // Cleanup
        ?>
		<div class="wrap pods-ui">
			<div id="icon-edit-pages" class="icon32"<?php 
        if (false !== $this->icon) {
            ?>
 style="background-position:0 0;background-size:100%;background-image:url(<?php 
            echo esc_url($this->icon);
            ?>
);"<?php 
        }
        ?>
><br /></div>
			<h2>
				<?php 
        echo $this->do_template($this->header['view']);
        if (!in_array('add', $this->actions_disabled) && !in_array('add', $this->actions_hidden)) {
            $link = pods_query_arg(array('action' . $this->num => 'add', 'id' . $this->num => '', 'do' . ($this->num = '')), self::$allowed, $this->exclusion());
            if (!empty($this->action_links['add'])) {
                $link = $this->action_links['add'];
            }
            ?>
					<a href="<?php 
            echo esc_url($link);
            ?>
" class="add-new-h2"><?php 
            echo $this->heading['add'];
            ?>
</a>
				<?php 
        } elseif (!in_array('manage', $this->actions_disabled) && !in_array('manage', $this->actions_hidden)) {
            $link = pods_query_arg(array('action' . $this->num => 'manage', 'id' . $this->num => ''), self::$allowed, $this->exclusion());
            if (!empty($this->action_links['manage'])) {
                $link = $this->action_links['manage'];
            }
            ?>
//.........这里部分代码省略.........
开发者ID:dylansmithing,项目名称:leader-of-rock-wordpress,代码行数:101,代码来源:PodsUI.php

示例4: save_pod_item


//.........这里部分代码省略.........
     }
     // Allow Helpers to bypass subsequent helpers in recursive save_pod_item calls
     $bypass_helpers = false;
     if (isset($params->bypass_helpers) && false !== $params->bypass_helpers) {
         $bypass_helpers = true;
     }
     // Allow Custom Fields not defined by Pods to be saved
     $allow_custom_fields = false;
     if (isset($params->allow_custom_fields) && false !== $params->allow_custom_fields) {
         $allow_custom_fields = true;
     }
     // Get array of Pods
     $pod = $this->load_pod(array('id' => $params->pod_id, 'name' => $params->pod, 'table_info' => true));
     if (false === $pod) {
         return pods_error(__('Pod not found', 'pods'), $this);
     }
     $params->pod = $pod['name'];
     $params->pod_id = $pod['id'];
     if ('settings' == $pod['type']) {
         $params->id = $pod['id'];
     }
     $fields = $pod['fields'];
     $object_fields = (array) pods_var_raw('object_fields', $pod, array(), null, true);
     $fields_active = array();
     $custom_data = array();
     // Find the active fields (loop through $params->data to retain order)
     if (!empty($params->data) && is_array($params->data)) {
         $custom_fields = array();
         foreach ($params->data as $field => $value) {
             if (isset($object_fields[$field])) {
                 $object_fields[$field]['value'] = $value;
                 $fields_active[] = $field;
             } elseif (isset($fields[$field])) {
                 if ('save' == $params->from || true === PodsForm::permission($fields[$field]['type'], $field, $fields[$field], $fields, $pod, $params->id, $params)) {
                     $fields[$field]['value'] = $value;
                     $fields_active[] = $field;
                 } elseif (!pods_has_permissions($fields[$field]['options']) && pods_var('hidden', $fields[$field]['options'], false)) {
                     $fields[$field]['value'] = $value;
                     $fields_active[] = $field;
                 }
             } else {
                 $found = false;
                 foreach ($object_fields as $object_field => $object_field_opt) {
                     if (in_array($field, $object_field_opt['alias'])) {
                         $object_fields[$object_field]['value'] = $value;
                         $fields_active[] = $object_field;
                         $found = true;
                         break;
                     }
                 }
                 if ($allow_custom_fields && !$found) {
                     $custom_fields[] = $field;
                 }
             }
         }
         if ($allow_custom_fields && !empty($custom_fields)) {
             foreach ($custom_fields as $field) {
                 $custom_data[$field] = $params->data[$field];
             }
         }
         if ($pod['type'] === 'taxonomy' && isset($params->data) && !empty($params->data)) {
             $term_data = $params->data;
         }
         unset($params->data);
     }
     if (empty($params->id) && !in_array('created', $fields_active) && isset($fields['created']) && in_array($fields['created']['type'], array('date', 'datetime'))) {
开发者ID:satokora,项目名称:IT354Project,代码行数:67,代码来源:PodsAPI.php

示例5: wp_enqueue_script

wp_enqueue_script('pods');
wp_enqueue_style('pods-form');
if (empty($fields) || !is_array($fields)) {
    $fields = $obj->pod->fields;
}
if (!isset($duplicate)) {
    $duplicate = false;
} else {
    $duplicate = (bool) $duplicate;
}
// unset fields
foreach ($fields as $k => $field) {
    if (in_array($field['name'], array('created', 'modified'))) {
        unset($fields[$k]);
    } elseif (false === PodsForm::permission($field['type'], $field['name'], $field['options'], $fields, $pod, $pod->id())) {
        if (pods_var('hidden', $field['options'], false)) {
            $fields[$k]['type'] = 'hidden';
        } elseif (pods_var('read_only', $field['options'], false)) {
            $fields[$k]['readonly'] = true;
        } else {
            unset($fields[$k]);
        }
    } elseif (!pods_has_permissions($field['options'])) {
        if (pods_var('hidden', $field['options'], false)) {
            $fields[$k]['type'] = 'hidden';
        } elseif (pods_var('read_only', $field['options'], false)) {
            $fields[$k]['readonly'] = true;
        }
    }
}
开发者ID:Ingenex,项目名称:redesign,代码行数:30,代码来源:form.php

示例6: save_comment

 /**
  * @param $comment_id
  */
 public function save_comment($comment_id)
 {
     $groups = $this->groups_get('comment', 'comment');
     if (empty($groups)) {
         return $comment_id;
     }
     $data = array();
     $id = $comment_id;
     $pod = null;
     foreach ($groups as $group) {
         if (empty($group['fields'])) {
             continue;
         }
         if (null === $pod) {
             $pod = pods($group['pod']['name'], $id, true);
         }
         foreach ($group['fields'] as $field) {
             if (false === PodsForm::permission($field['type'], $field['name'], $field, $group['fields'], $pod, $id)) {
                 if (!pods_var('hidden', $field['options'], false, null, true)) {
                     continue;
                 }
             }
             $data[$field['name']] = '';
             if (isset($_POST['pods_meta_' . $field['name']])) {
                 $data[$field['name']] = $_POST['pods_meta_' . $field['name']];
             }
         }
     }
     do_action('pods_meta_save_pre_comment', $data, $pod, $id, $groups);
     if (!empty($pod)) {
         // Fix for Pods doing it's own sanitization
         $data = stripslashes_deep($data);
         $pod->save($data);
     } elseif (!empty($id)) {
         pods_no_conflict_on('comment');
         foreach ($data as $field => $value) {
             update_comment_meta($id, $field, $value);
         }
         pods_no_conflict_off('comment');
     }
     do_action('pods_meta_save_comment', $data, $pod, $id, $groups);
     return $comment_id;
 }
开发者ID:centaurustech,项目名称:chipin,代码行数:46,代码来源:PodsMeta.php

示例7: save_comment

 /**
  * @param $comment_id
  */
 public function save_comment($comment_id)
 {
     $groups = $this->groups_get('comment', 'comment');
     if (empty($groups)) {
         return $comment_id;
     } elseif (empty($_POST)) {
         return $comment_id;
     } elseif (!wp_verify_nonce(pods_v('pods_meta', 'post'), 'pods_meta_comment')) {
         return $comment_id;
     }
     $data = array();
     $id = $comment_id;
     $pod = null;
     foreach ($groups as $group) {
         if (empty($group['fields'])) {
             continue;
         }
         if (null === $pod || is_object($pod) && $pod->id() != $id) {
             if (!is_object(self::$current_pod) || self::$current_pod->pod != $group['pod']['name']) {
                 self::$current_pod = pods($group['pod']['name'], $id, true);
             } elseif (self::$current_pod->id() != $id) {
                 self::$current_pod->fetch($id);
             }
             $pod = self::$current_pod;
         }
         foreach ($group['fields'] as $field) {
             if (false === PodsForm::permission($field['type'], $field['name'], $field, $group['fields'], $pod, $id)) {
                 if (!pods_var('hidden', $field['options'], false)) {
                     continue;
                 }
             }
             $data[$field['name']] = '';
             if (isset($_POST['pods_meta_' . $field['name']])) {
                 $data[$field['name']] = $_POST['pods_meta_' . $field['name']];
             }
         }
     }
     do_action('pods_meta_save_pre_comment', $data, $pod, $id, $groups);
     if (!empty($pod)) {
         // Fix for Pods doing it's own sanitization
         $data = pods_unslash((array) $data);
         $pod->save($data);
     } elseif (!empty($id)) {
         pods_no_conflict_on('comment');
         foreach ($data as $field => $value) {
             update_comment_meta($id, $field, $value);
         }
         pods_no_conflict_off('comment');
     }
     do_action('pods_meta_save_comment', $data, $pod, $id, $groups);
     return $comment_id;
 }
开发者ID:talentedunicorn,项目名称:pods,代码行数:55,代码来源:PodsMeta.php

示例8: input

 /**
  * Customize output of the form field
  *
  * @param string $name
  * @param mixed $value
  * @param array $options
  * @param array $pod
  * @param int $id
  *
  * @since 2.0
  */
 public function input($name, $value = null, $options = null, $pod = null, $id = null)
 {
     $options = (array) $options;
     $form_field_type = PodsForm::$field_type;
     if (is_array($value)) {
         $value = implode("\n", $value);
     }
     if (isset($options['name']) && false === PodsForm::permission(self::$type, $options['name'], $options, null, $pod, $id)) {
         if (pods_var('read_only', $options, false)) {
             $options['readonly'] = true;
             $field_type = 'textarea';
         } else {
             return;
         }
     } elseif (!pods_has_permissions($options) && pods_var('read_only', $options, false)) {
         $options['readonly'] = true;
         $field_type = 'textarea';
     } elseif ('tinymce' == pods_var(self::$type . '_editor', $options)) {
         $field_type = 'tinymce';
     } elseif ('cleditor' == pods_var(self::$type . '_editor', $options)) {
         $field_type = 'cleditor';
     } else {
         // Support custom WYSIWYG integration
         do_action('pods_form_ui_field_wysiwyg_' . pods_var(self::$type . '_editor', $options), $name, $value, $options, $pod, $id);
         do_action('pods_form_ui_field_wysiwyg', pods_var(self::$type . '_editor', $options), $name, $value, $options, $pod, $id);
         return;
     }
     pods_view(PODS_DIR . 'ui/fields/' . $field_type . '.php', compact(array_keys(get_defined_vars())));
 }
开发者ID:dylansmithing,项目名称:leader-of-rock-wordpress,代码行数:40,代码来源:wysiwyg.php

示例9: view

 /**
  * @param array $fields (optional) Fields to show in the view, defaults to all fields
  *
  * @return mixed
  * @since 2.3.10
  */
 public function view($fields = null)
 {
     $pod =& $this;
     // Convert comma separated list of fields to an array
     if (null !== $fields && !is_array($fields) && 0 < strlen($fields)) {
         $fields = explode(',', $fields);
     }
     $object_fields = (array) pods_v('object_fields', $this->pod_data, array(), true);
     if (empty($fields)) {
         // Add core object fields if $fields is empty
         $fields = array_merge($object_fields, $this->fields);
     }
     $view_fields = $fields;
     // Temporary
     $fields = array();
     foreach ($view_fields as $name => $field) {
         $defaults = array('name' => $name);
         if (!is_array($field)) {
             $name = $field;
             $field = array('name' => $name);
         }
         $field = array_merge($defaults, $field);
         $field['name'] = trim($field['name']);
         if (empty($field['name'])) {
             $field['name'] = trim($name);
         }
         if (isset($object_fields[$field['name']])) {
             $field = array_merge($field, $object_fields[$field['name']]);
         } elseif (isset($this->fields[$field['name']])) {
             $field = array_merge($this->fields[$field['name']], $field);
         }
         if (pods_v('hidden', $field, false, null, true) || 'hidden' == $field['type']) {
             continue;
         } elseif (!PodsForm::permission($field['type'], $field['name'], $field['options'], $fields, $pod, $pod->id())) {
             continue;
         }
         $fields[$field['name']] = $field;
     }
     unset($view_fields);
     // Cleanup
     $output = pods_view(PODS_DIR . 'ui/front/view.php', compact(array_keys(get_defined_vars())), false, 'cache', true);
     return $this->do_hook('view', $output, $fields, $this->id());
 }
开发者ID:erkmen,项目名称:wpstartersetup,代码行数:49,代码来源:Pods.php


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