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


PHP Skin::can_edit方法代码示例

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


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

示例1: get_myskins_data

 /**
  * Returns data about available skins. Tightly coupled with view/skin.php, which uses it to
  * display the skins picker
  * @param int $limit
  * @param int $offset
  * @param string $filter Should be: all, public, user, or site
  * @return object
  */
 public static function get_myskins_data($limit = 9, $offset = 0, $filter = 'all')
 {
     global $USER;
     $userid = $USER->get('id');
     $owner = null;
     $favorites = get_field('skin_favorites', 'favorites', 'user', $userid);
     $favorites = unserialize($favorites);
     if (!is_array($favorites)) {
         $favorites = array();
     }
     $sort = 'title, id';
     $cols = 'id, title, description, owner, type, ctime, mtime';
     switch ($filter) {
         case 'public':
             $count = count_records('skin', 'type', 'public');
             $skindata = get_records_array('skin', 'type', 'public', $sort, $cols, $offset, $limit);
             break;
         case 'user':
             $count = count_records_select('skin', 'owner = ? and type != ?', array($userid, 'site'));
             $skindata = get_records_select_array('skin', 'owner = ? and type != ?', array($userid, 'site'), $sort, $cols, $offset, $limit);
             break;
         case 'site':
             $count = count_records('skin', 'type', 'site');
             $skindata = get_records_array('skin', 'type', 'site', $sort, $cols, $offset, $limit);
             break;
         default:
             $count = count_records_select('skin', 'owner = ? or type in (?, ?)', array($userid, 'site', 'public'));
             $skindata = get_records_select_array('skin', 'owner = ? or type in (?, ?)', array($userid, 'site', 'public'), $sort, $cols, $offset, $limit);
             break;
     }
     $data = array();
     if ($skindata) {
         for ($i = 0; $i < count($skindata); $i++) {
             $skinobj = new Skin(0, $skindata[$i]);
             $index[$skindata[$i]->id] = $i;
             $data[$i]['id'] = $skindata[$i]->id;
             $data[$i]['title'] = $skindata[$i]->title;
             $data[$i]['owner'] = $skindata[$i]->owner;
             $data[$i]['type'] = $skindata[$i]->type;
             if ($skinobj->can_edit()) {
                 $data[$i]['removable'] = true;
                 $data[$i]['editable'] = true;
             }
             if (in_array($skindata[$i]->id, $favorites)) {
                 $data[$i]['favorite'] = true;
             } else {
                 $data[$i]['favorite'] = false;
             }
             $owner = new User();
             $owner->find_by_id($skindata[$i]->owner);
             $data[$i]['metadata'] = array('displayname' => display_name($owner), 'profileurl' => profile_url($owner), 'description' => nl2br($skindata[$i]->description), 'ctime' => format_date(strtotime($skindata[$i]->ctime)), 'mtime' => format_date(strtotime($skindata[$i]->mtime)));
         }
     }
     return (object) array('data' => $data, 'count' => $count);
 }
开发者ID:sarahjcotton,项目名称:mahara,代码行数:63,代码来源:skin.php

示例2: redirect

        redirect();
    }
    define('MENUITEM', 'configsite/siteskins');
    $goto = '/admin/site/skins.php';
    $redirect = '/admin/site/skins.php';
} else {
    define('MENUITEM', 'myportfolio/skins');
    $goto = '/skin/index.php';
    $redirect = '/skin/index.php';
}
$id = param_integer('id', 0);
// id of Skin to be edited...
$skindata = null;
if ($id > 0) {
    $skinobj = new Skin($id);
    if ($skinobj->can_edit()) {
        $viewskin = $skinobj->get('viewskin');
        // check to see if any background images being referenced have not
        // been deleted from site and if they have set the value to false
        if (!empty($viewskin['body_background_image'])) {
            if (!record_exists('artefact', 'id', $viewskin['body_background_image'])) {
                $viewskin['body_background_image'] = false;
            }
        }
        if (!empty($viewskin['view_background_image'])) {
            if (!record_exists('artefact', 'id', $viewskin['view_background_image'])) {
                $viewskin['view_background_image'] = false;
            }
        }
    } else {
        throw new AccessDeniedException("You can't access and/or edit Skin with id {$id}");
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:31,代码来源:design.php

示例3: deleteskin_submit

require_once 'skin.php';
require_once 'pieforms/pieform.php';
$skinid = param_integer('id');
$siteskin = param_boolean('site', false);
if (!can_use_skins(null, $siteskin)) {
    throw new FeatureNotEnabledException();
}
if ($siteskin) {
    $goto = 'admin/site/skins.php';
    $redirect = '/admin/site/skins.php';
} else {
    $goto = 'skin/index.php';
    $redirect = '/skin/index.php';
}
$skin = new Skin($skinid, null);
if (!$skin->can_edit()) {
    throw new AccessDeniedException(get_string('cantdeleteskin', 'skin'));
}
define('TITLE', get_string('deletespecifiedskin', 'skin', $skin->get('title')));
$numberofpagesuseskin = count_records('view', 'skin', $skin->get('id'));
$form = pieform(array('name' => 'deleteskin', 'autofocus' => false, 'renderer' => 'div', 'method' => 'post', 'elements' => array('submit' => array('type' => 'submitcancel', 'value' => array(get_string('yes'), get_string('no')), 'goto' => get_config('wwwroot') . $goto))));
$smarty = smarty();
$smarty->assign('PAGEHEADING', get_string('deletespecifiedskin', 'skin', $skin->get('title')));
$smarty->assign('safemessage', ($numberofpagesuseskin > 0 ? get_string('deleteskinusedinpages', 'skin', $numberofpagesuseskin) . '<br/>' : '') . get_string('deleteskinconfirm', 'skin'));
$smarty->assign('form', $form);
$smarty->display('skin/delete.tpl');
function deleteskin_submit(Pieform $form, $values)
{
    global $SESSION, $USER, $skinid, $redirect;
    $skin = new Skin($skinid, null);
    if ($skin->get('owner') == $USER->get('id') || $USER->get('admin')) {
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:31,代码来源:delete.php


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