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


PHP WikiPage::canAdd方法代码示例

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


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

示例1: wiki_my_tasks_dropdown

function wiki_my_tasks_dropdown()
{
    echo '<li class="header"><a href="' . get_url('wiki', 'index') . '">' . lang('wiki') . '</a></li>';
    if (WikiPage::canAdd(logged_user(), active_project())) {
        echo '<li><a href="' . get_url('wiki', 'add') . '">' . lang('add wiki page') . '</a></li>';
    }
    // if
}
开发者ID:bklein01,项目名称:Project-Pier,代码行数:8,代码来源:init.php

示例2: add

 /**
  * Add a wiki page
  *
  * @return void
  */
 function add()
 {
     if (!WikiPage::canAdd(logged_user(), active_project())) {
         flash_error(lang('no access permissions'));
         $this->redirectTo('wiki');
     }
     //if
     //Here we will edit a wiki page
     $preview = false;
     $data = array_var($_POST, 'wiki', false);
     if (false !== $data) {
         $preview = array_key_exists('preview', $data);
     }
     if (!$preview && $data) {
         //Make a new wiki page
         $page = new WikiPage();
         //Set the Id for this project
         $page->setProjectId(active_project()->getId());
         $page->setProjectIndex(logged_user()->isMemberOfOwnerCompany() ? $data['project_index'] : 0);
         $page->setPublish(logged_user()->isMemberOfOwnerCompany() ? $data['publish'] : 0);
         $page->setParentId($data['parent_id']);
         $page->setProjectSidebar(logged_user()->isMemberOfOwnerCompany() ? $data['project_sidebar'] : 0);
         //Make a new revision of this page
         $revision = $page->makeRevision();
         // Check to see if we want to lock this page
         if (isset($data['locked'])) {
             if ($data['locked'] == 1 && $page->canLock(logged_user())) {
                 // If we want to lock this page and the user has permissions to lock it, and the page is not already locked
                 $page->setLocked(true);
                 $page->setLockedById(logged_user()->getId());
                 $page->setLockedOn(DateTimeValueLib::now());
             }
             // if
         }
         // if
         //Set attributes from form
         $revision->setFromAttributes($data);
         //Set user ID and project ID
         $revision->setCreatedbyId(logged_user()->getId());
         try {
             //Start the db transaction
             DB::beginWork();
             //Save the page
             $page->save();
             //Make a log entry
             ApplicationLogs::createLog($page, active_project(), ApplicationLogs::ACTION_ADD);
             if (plugin_active('tags')) {
                 //Add page tags
                 $page->setTagsFromCSV($data['tags']);
             }
             //Commit changed
             DB::commit();
             //Tell the user they made a page
             flash_success(lang('success add wiki page'));
             //Redirect
             $this->redirectToUrl($page->getViewUrl());
         } catch (Exception $e) {
             DB::rollback();
             tpl_assign('error', $e);
         }
         //try
     }
     // if
     if (!isset($page) || !instance_of($page, 'WikiPage')) {
         $page = new WikiPage();
         $page->setProjectId(active_project()->getId());
     }
     // if
     $revision = new Revision();
     if (!$data) {
         // there was no input POSTed
         $data['content'] = $revision->getContent();
     }
     $data['preview_content'] = do_textile($data['content']);
     //Assign revision object
     tpl_assign('data', $data);
     tpl_assign('page', $page);
     tpl_assign('revision', $revision);
     tpl_assign('tags', '');
     $this->setTemplate('edit');
     $this->setSidebar(get_template_path('textile_help_sidebar'));
 }
开发者ID:bklein01,项目名称:Project-Pier,代码行数:87,代码来源:WikiController.class.php

示例3: add

 /**
  * Add a wiki page
  *
  * @return void
  */
 function add()
 {
     if (!WikiPage::canAdd(logged_user(), active_project())) {
         flash_error(lang('no access permissions'));
         $this->redirectTo('wiki');
     }
     //if
     if (false !== ($data = array_var($_POST, 'wiki', false))) {
         //Make a new wiki page
         $page = new WikiPage();
         //Set the Id for this project
         $page->setProjectId(active_project()->getId());
         $page->setProjectIndex(logged_user()->isMemberOfOwnerCompany() ? $data['project_index'] : 0);
         $page->setProjectSidebar(logged_user()->isMemberOfOwnerCompany() ? $data['project_sidebar'] : 0);
         //Make a new revision of this page
         $revision = $page->makeRevision();
         //Set attributes from form
         $revision->setFromAttributes($data);
         //Set user ID and project ID
         $revision->setCreatedbyId(logged_user()->getId());
         try {
             //Start the db transaction
             DB::beginWork();
             //Save the page
             $page->save();
             //Make a log entry
             ApplicationLogs::createLog($page, active_project(), ApplicationLogs::ACTION_ADD);
             if (plugin_active('tags')) {
                 //Add page tags
                 $page->setTagsFromCSV($data['tags']);
             }
             //Commit changed
             DB::commit();
             //Tell the user they made a page
             flash_success(lang('success add wiki page'));
             //Redirect
             $this->redirectToUrl($page->getViewUrl());
         } catch (Exception $e) {
             DB::rollback();
             tpl_assign('error', $e);
         }
         //try
     }
     // if
     if (!isset($page) || !instance_of($page, 'WikiPage')) {
         $page = new WikiPage();
         $page->setProjectId(active_project()->getId());
     }
     // if
     tpl_assign('page', $page);
     tpl_assign('revision', new Revision());
     $this->setTemplate('edit');
 }
开发者ID:469306621,项目名称:Languages,代码行数:58,代码来源:WikiController.class.php


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