Mahara/Edit_Journal2

日誌ブロックに「編集する」リンクを表示する

1.8.0に変更を加えたところです。

artefact/blog/lib.php

$ diff -c lib.php.org lib.php
*** lib.php.org 2013-11-06 23:06:43.215451811 +0900
--- lib.php     2013-11-07 00:04:01.141244748 +0900
***************
*** 642,647 ****
--- 642,661 ----
          $smarty->assign('postedbyon', get_string('postedbyon', 'artefact.blog',
                                                   display_name($this->owner),
                                                   format_date($this->ctime)));
+ 
+       // added by sumi (2013-11-06)
+       global $USER;
+       global $exporter;
+       $exporting = isset($exporter);
+       $smarty->assign('viewbyowner',(!$exporting && ($USER->id==$this->owner || $USER->id==$this->author))? 1:0);
+       $smarty->assign('post_is_not_locked',!$this->get('locked'));
+ 
+       $sv=param_integer('id',0); 
+       $smarty->assign('savepar',sprintf("&sartefact=%d&sview=%d", 
+                                           param_integer('artefact',0), 
+                                           ( ($sv>0)? $sv:param_integer('view',0)))); 
+       // end
+ 
          return array('html' => $smarty->fetch('artefact:blog:render/blogpost_renderfull.tpl'),
                       'javascript' => '');
      }
***************
*** 696,716 ****
  
          $results['count'] = count_records_sql('SELECT COUNT(*) ' . $from, array($id));
  
          $data = get_records_sql_assoc('
              SELECT
                  a.id, a.title, a.description, a.author, a.authorname, ' .
                  db_format_tsfield('a.ctime', 'ctime') . ', ' . db_format_tsfield('a.mtime', 'mtime') . ',
!                 a.locked, bp.published, a.allowcomments ' . $from . '
              ORDER BY bp.published ASC, a.ctime DESC, a.id DESC',
              array($id),
              $offset, $limit
          );
  
          if (!$data) {
              $results['data'] = array();
              return $results;
          }
  
          // Get the attached files.
          $postids = array_map(create_function('$a', 'return $a->id;'), $data);
          $files = ArtefactType::attachments_from_id_list($postids);
--- 710,739 ----
  
          $results['count'] = count_records_sql('SELECT COUNT(*) ' . $from, array($id));
  
+       // modified by sumi (2013-11-06)
          $data = get_records_sql_assoc('
              SELECT
                  a.id, a.title, a.description, a.author, a.authorname, ' .
                  db_format_tsfield('a.ctime', 'ctime') . ', ' . db_format_tsfield('a.mtime', 'mtime') . ',
!                 a.locked, bp.published, a.allowcomments,a.parent ' . $from . '
              ORDER BY bp.published ASC, a.ctime DESC, a.id DESC',
              array($id),
              $offset, $limit
          );
+       // end
  
          if (!$data) {
              $results['data'] = array();
              return $results;
          }
  
+       // added by sumi (2013-11-06)
+       // check if the view is submitted or not
+       if ( isset($viewoptions['viewid']) ) {
+         $submitted = (get_field('view','submittedgroup','id',$viewoptions['viewid'])>0)? 1:0;
+       }
+       // end
+ 
          // Get the attached files.
          $postids = array_map(create_function('$a', 'return $a->id;'), $data);
          $files = ArtefactType::attachments_from_id_list($postids);
***************
*** 757,762 ****
--- 780,799 ----
                  safe_require('artefact', 'file');
                  $post->description = ArtefactTypeFolder::append_view_url($post->description, $viewoptions['viewid']);
              }
+ 
+           // added by sumi (2013-11-06)
+           global $USER;
+           global $exporter;
+           $exporting = isset($exporter);
+           $post->viewbyowner=( (!$exporting && ($post->owner==$USER->id || $post->author==$USER->id))? 1:0); 
+           $post->is_not_locked = !$post->locked;
+           $post->parent_view_is_not_submitted = !$submitted;
+ 
+           $sv=param_integer('id',0); 
+           $post->savepar = sprintf("&sartefact=%d&sview=%d", 
+                                    param_integer('artefact',0), 
+                                    ( ($sv>0)? $sv:param_integer('view',0))); 
+           // end
          }
  
          $results['data'] = array_values($data);

artefact/blog/post.php

$ diff -c post.php.org post.php
*** post.php.org        2013-11-06 23:17:44.879375201 +0900
--- post.php    2013-11-06 23:22:33.132895445 +0900
***************
*** 22,27 ****
--- 22,39 ----
  safe_require('artefact', 'blog');
  safe_require('artefact', 'file');
  
+ // added by sumi (2013-11-06)
+ function wayback_url ($blog,$sview,$sartefact) {
+   if  ( $sview==0 ) { 
+     return 'artefact/blog/view/index.php?id='.$blog; 
+   } elseif ( $sartefact==0 ) { 
+     return 'view/view.php?id=' . $sview; 
+   } else { 
+     return 'view/artefact.php?artefact='. $sartefact.'&view=' . $sview; 
+   } 
+ } 
+ // end
+ 
  /* 
   * For a new post, the 'blog' parameter will be set to the blog's
   * artefact id.  For an existing post, the 'blogpost' parameter will
***************
*** 73,78 ****
--- 85,94 ----
      $highlight = array($file);
  }
  
+ // added by sumi (2013-11-06)
+ $sview = param_integer('sview',0);
+ $sartefact = param_integer('sartefact',0);
+ // end
  
  $form = pieform(array(
      'name'               => 'editpost',
***************
*** 161,167 ****
          'submitpost' => array(
              'type' => 'submitcancel',
              'value' => array(get_string('savepost', 'artefact.blog'), get_string('cancel')),
!             'goto' => get_config('wwwroot') . 'artefact/blog/view/index.php?id=' . $blog,
          )
      )
  ));
--- 177,185 ----
          'submitpost' => array(
              'type' => 'submitcancel',
              'value' => array(get_string('savepost', 'artefact.blog'), get_string('cancel')),
!           // modified by sumi (2013-11-06)
!           'goto' => get_config('wwwroot') . wayback_url($blog,$sview,$sartefact),
!           // end
          )
      )
  ));
***************
*** 319,329 ****
          }
      }
      db_commit();
  
      $result = array(
          'error'   => false,
          'message' => get_string('blogpostsaved', 'artefact.blog'),
!         'goto'    => get_config('wwwroot') . 'artefact/blog/view/index.php?id=' . $blog,
      );
      if ($form->submitted_by_js()) {
          // Redirect back to the blog page from within the iframe
--- 337,353 ----
          }
      }
      db_commit();
+     
+     // added by sumi (2013-11-06)
+     global $sview,$sartefact;
+     // end
  
      $result = array(
          'error'   => false,
          'message' => get_string('blogpostsaved', 'artefact.blog'),
!       // modified by sumi (2013-11-06)
!         'goto'    => get_config('wwwroot') . wayback_url($blog,$sview,$sartefact),
!       // end
      );
      if ($form->submitted_by_js()) {
          // Redirect back to the blog page from within the iframe

artefact/blog/theme/raw/viewposts.tpl

$ diff -c viewposts.tpl.org viewposts.tpl
*** viewposts.tpl.org   2013-11-06 23:23:41.455440793 +0900
--- viewposts.tpl       2013-11-07 00:14:37.174685090 +0900
***************
*** 22,27 ****
      </table>
      {/if}
      <div class="postdetails">{$post->postedby}
!     {if $options.viewid && $post->allowcomments} | <a href="{$WWWROOT}view/artefact.php?artefact={$post->id}&view={$options.viewid}">{str tag=Comments section=artefact.comment} ({$post->commentcount})</a>{/if}</div>
  </div>
  {/foreach}
--- 22,37 ----
      </table>
      {/if}
      <div class="postdetails">{$post->postedby}
!     {if $options.viewid && $post->allowcomments} | <a href="{$WWWROOT}view/artefact.php?artefact={$post->id}&view={$options.viewid}">{str tag=Comments section=artefact.comment} ({$post->commentcount})</a>{/if}
!             {if $post->viewbyowner}
!            {if $post->is_not_locked}
!               | <a href="{$WWWROOT}artefact/blog/post.php?id={$post->id}{$post->savepar}"> 
!                  {str tag=editblogpost section=artefact.blog}</a> 
!            {/if}
!              {if $post->parent_view_is_not_submitted}
!               | <a href="{$WWWROOT}artefact/blog/post.php?blog={$post->parent}{$post->savepar}"> 
!                  {str tag=addpost section=artefact.blog}</a> 
!              {/if}
!             {/if}</div>                  
  </div>
  {/foreach}

artefact/blog/theme/raw/render/blogpost_renderfull.tpl

$ diff -c blogpost_renderfull.tpl.org blogpost_renderfull.tpl
*** blogpost_renderfull.tpl.org 2013-11-06 23:29:04.002737382 +0900
--- blogpost_renderfull.tpl     2013-11-07 00:06:38.181808928 +0900
***************
*** 22,27 ****
--- 22,32 ----
    <div class="postdetails">{$postedbyon}
      {if isset($commentcount) && $artefact->get('allowcomments')} | <a href="{$artefacturl}">{str tag=Comments section=artefact.comment} ({$commentcount})</a>{/if}
  
+             {if $viewbyowner && $post_is_not_locked} 
+               | <a href="{$WWWROOT}artefact/blog/post.php?id={$artefact->get('id')}{$savepar}"> 
+                  {str tag=editblogpost section=artefact.blog}</a> 
+             {/if} 
+ 
    </div>
    {if $license}
      <div class="postlicense">

トップ   差分 バックアップ リロード   一覧 単語検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2013-11-07 (木) 00:26:59 (1447d)