Dotclear

Changeset 3423:e34ec8af1a67 for inc


Ignore:
Timestamp:
11/26/16 11:53:12 (9 years ago)
Author:
Jean-Christian Denis
Branch:
default
Message:

Add First Publication mecanism, closes #970, adresses #784, #843, #871, #548

Location:
inc
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • inc/core/class.dc.blog.php

    r3340 r3423  
    832832               'post_tz, post_creadt, post_upddt, post_format, post_password, '. 
    833833               'post_url, post_lang, post_title, '.$content_req. 
    834                'post_type, post_meta, post_status, post_selected, post_position, '. 
     834               'post_type, post_meta, '. 
     835               'post_status, post_firstpub, post_selected, post_position, '. 
    835836               'post_open_comment, post_open_tb, nb_comment, nb_trackback, '. 
    836837               'U.user_name, U.user_firstname, U.user_displayname, U.user_email, '. 
     
    928929          if (isset($params['post_status'])) { 
    929930               $strReq .= 'AND post_status = '.(integer) $params['post_status'].' '; 
     931          } 
     932 
     933          if (isset($params['post_firstpub'])) { 
     934               $strReq .= 'AND post_firstpub = '.(integer) $params['post_firstpub'].' '; 
    930935          } 
    931936 
     
    13191324          $this->triggerBlog(); 
    13201325 
     1326          $this->firstPublicationEntries($cur->post_id); 
     1327 
    13211328          return $cur->post_id; 
    13221329     } 
     
    13791386 
    13801387          $this->triggerBlog(); 
     1388 
     1389          $this->firstPublicationEntries($id); 
    13811390     } 
    13821391 
     
    14231432          $cur->update($strReq); 
    14241433          $this->triggerBlog(); 
     1434 
     1435          $this->firstPublicationEntries($posts_ids); 
    14251436     } 
    14261437 
     
    16281639               # --BEHAVIOR-- coreAfterScheduledEntriesPublish 
    16291640               $this->core->callBehavior('coreAfterScheduledEntriesPublish',$this,$to_change); 
    1630           } 
    1631  
     1641 
     1642               $this->firstPublicationEntries($to_change); 
     1643          } 
     1644     } 
     1645 
     1646     /** 
     1647     First publication mecanism (on post create, update, publish, status) 
     1648 
     1649     @param    ids       <b>mixed</b>        Post(s) ID(s) 
     1650     */ 
     1651     public function firstPublicationEntries($ids) 
     1652     { 
     1653          $posts = $this->getPosts(array( 
     1654               'post_id' => dcUtils::cleanIds($ids), 
     1655               'post_status' => 1, 
     1656               'post_firstpub' => 0 
     1657          )); 
     1658 
     1659          $to_change = array(); 
     1660          while($posts->fetch()) { 
     1661 
     1662               $to_change[] = $posts->post_id;  
     1663          } 
     1664 
     1665          if (count($to_change)) { 
     1666 
     1667               $strReq = 
     1668               'UPDATE '.$this->prefix.'post '. 
     1669               'SET post_firstpub = 1 '. 
     1670               "WHERE blog_id = '".$this->con->escape($this->id)."' ". 
     1671               'AND post_id '.$this->con->in((array)$to_change).' '; 
     1672               $this->con->execute($strReq); 
     1673 
     1674               # --BEHAVIOR-- coreFirstPublicationEntries 
     1675               $this->core->callBehavior('coreFirstPublicationEntries',$this,$to_change); 
     1676          } 
    16321677     } 
    16331678 
     
    17601805 
    17611806               $cur->post_words = implode(' ',text::splitWords($words)); 
     1807          } 
     1808 
     1809          if ($cur->isField('post_firstpub')) { 
     1810               $cur->unsetField('post_firstpub'); 
    17621811          } 
    17631812     } 
  • inc/dbschema/db-schema.php

    r3231 r3423  
    121121     ->post_words             ('text',       0,        true,     null) 
    122122     ->post_status            ('smallint',   0,        false,    0) 
     123     ->post_firstpub               ('smallint',   0,        false,    0) 
    123124     ->post_selected               ('smallint',   0,        false,    0) 
    124125     ->post_position               ('integer',         0,        false,    0) 
  • inc/dbschema/upgrade.php

    r3420 r3423  
    610610               $core->con->execute($strReq); 
    611611 
     612               # Update first publication on published posts 
     613               $strReq = 'UPDATE '.$core->prefix.'post '. 
     614                         'SET post_firstpub = 1 '. 
     615                         'WHERE post_status = 1 '; 
     616               $core->con->execute($strReq); 
     617 
    612618               # A bit of housecleaning for no longer needed files 
    613619               $remfiles = array ( 
Note: See TracChangeset for help on using the changeset viewer.

Sites map