Log in | Register | Lost password

Bottom
Setting expire date
  • Posted: 17.01.2007, 00:07
     
    Converted
    rank:
    12
    registered:
     March 2009
    Status:
    offline
    last visit:
    Posts:
    0
    Has anyone found a way to modify a publication's expire date upon submission? I'd like to set it to something like 2 weeks in the future or something like that.

    Also, for a bonus 100 points, I'd like to be able to e-mail the publication's author before the publication expires.

    I will pay money for this.
  • Posted: 28.01.2007, 03:13
     
    Converted
    rank:
    12
    registered:
     March 2009
    Status:
    offline
    last visit:
    Posts:
    0
    anyone know of a better place to hire a pagesetter programmer?
  • Posted: 05.03.2007, 05:26
     
    Converted
    rank:
    12
    registered:
     March 2009
    Status:
    offline
    last visit:
    Posts:
    0
    cityweaver had this feature so I know it can be done.....
  • Posted: 06.03.2007, 02:02
     
    Converted
    rank:
    12
    registered:
     March 2009
    Status:
    offline
    last visit:
    Posts:
    0
    hello yee You want it for classfields
    I solved it in this way
    I make, a operation witch is similar to createPublication with this lines:

    Code

    $days = (isset($args['DAYS']) ? $args['DAYS'] : 20);



    $days = date('Y-m-d',mktime(0, 0, 0, date("m") , date("d")+ $days, date("Y")));





    $publication['core_expireDate'] = $days;


    now i have workflow like that:

    Code

    <action id="submit">

    <title>Submit</title>

    <description>Submit new content</description>

    <permission>author</permission>

    <nextState>approved</nextState>

    <operation online="1" days="20">changeExpired</operation>



    </action>


    i change newFormLayout (remove islands at the bottom author dates and location )
    and it was working untill i turn on edit option
    and change approvedFormLayout
    So user submit new pub its online with changed expireDate then when he want to edit his own pub it shows error unknow pub(his pub dissapear from list) so i check that in admin list and it shows his pub changed but expireDate was set on 1970:)
    I try readonly in formLayout and nothing.
    Edit is working only when the expireDate is on but thats no good:(
    This is my edit action:

    Code

    <action id="update">

    <title>Update</title>

    <description>Update content</description>

    <permission>author and owner or editor</permission>

    <state>approved</state>



    <operation>moveToDepot</operation>

    <operation nextState="approved" online="1">createNewRevisionWithDate</operation>

    </action>

    and operation :

    Code

    function pagesetter_operation_createNewRevisionWithDate(&$publication, &$core, &$args)

    {

    if (!isset($args['NEXTSTATE']))

    return;



    $nextState = $args['NEXTSTATE'];

    $online = (isset($args['ONLINE']) ? $args['ONLINE'] : 0);



    $tid = $core['tid'];

    $pid = $core['pid'];



    $publication['core_approvalState'] = $nextState;

    $publication['core_online'] = $online;





    $days = (isset($args['DAYS']) ? $args['DAYS'] : 20);



    $days = date('Y-m-d',mktime(0, 0, 0, date("m") , date("d")+ $days, date("Y")));





    $publication['core_expireDate'] = $days;







    $newInfo = pnModAPIFunc( 'pagesetter', 'edit', 'createNewRevision',

    array( 'tid' => $tid,

    'id' => $core['id'],

    'copyCreatedDate' => true,

    'pubData' => $publication) );



    ...

    But when user is editing his own pub when the expireDate is coming he will get next 20 days:(
    It is temporary I'm looking for solution now.

    What is intresting that copyCreatedDate.??why copy it this way??

    I have questions
    How can I get the old expireDate in operation??
    Do you know any other solution??
  • Posted: 10.09.2007, 14:26
     
    Converted
    rank:
    12
    registered:
     March 2009
    Status:
    offline
    last visit:
    Posts:
    0
    Hi.

    I'm confused :-? .
    If I use the code from kaik, theres no expired date in dy DB. If I use this code, I'll get the expiredDate but the pub generate a twin :-). I know why: there are two operations for a new pup, BUT
    If I delete the normal operation in Line 6:

    Code

    <operation>createPublication</operation>

    theres already no expireDate in the DB.

    Code

    <action id="submit">

    <title>Submit</title>

    <description>Submit new content for acceptance by the local moderator</description>

    <permission>author</permission>

    <operation online="1" days="20">expireDate</operation>

    <nextState>waiting</nextState>

    <operation>createPublication</operation>

    <operation recipient="$moderatorMails" message="$notificationText" subject="$notificationSubject">mailNewContentMessage</operation>

    </action>


    What ist the mistake?
    Here ist my operation: expireDate.php

    Code

    <?php



    function pagesetter_operation_expireDate(&$publication, &$core, &$args)

    {

    $online = (isset($args['ONLINE']) ? $args['ONLINE'] : 0);



    $publication['core_online'] = $online;



    $result = pnModAPIFunc( 'pagesetter',

    'edit',

    'createPub',

    array( 'tid' => $core['tid'],

    'pubData' => $publication) );





    //============================== ExpireDate ==============================



    $days = (isset($args['DAYS']) ? $args['DAYS'] : 20);

    $days = date('Y-m-d',mktime(0, 0, 0, date("m") , date("d")+ $days, date("Y")));

    $publication['core_expireDate'] = $days;



    //========================================================================





    if ($result === false)

    return pagesetterWFOperationError;



    $id = $core['id'] = $result['id'];





    // Inform Folder module of new publication

    // - place either in selected folder when called from folder module

    // or in default folder

    if (pnModAPILoad('folder', 'user'))

    {

    $tid = $result['tid'];

    $pid = $result['pid'];



    // Get complete publication info - not only what was edited.

    $publication = pnModAPIFunc( 'pagesetter', 'user', 'getPub',

    array('tid' => $tid,

    'id' => $id,

    'format' => 'user') );

    if ($publiation === false)

    return pagesetterWFOperationError;



    $pubInfo = pnModAPIFunc( 'pagesetter', 'admin', 'getPubTypeInfo',

    array('tid' => $tid) );

    if ($pubInfo === false)

    return pagesetterWFOperationError;



    $titleFieldId = $pubInfo['publication']['titleFieldID'];

    foreach ($pubInfo['fields'] as $field)

    if ($field['id'] == $titleFieldId)

    $title = $publication[$field['name']];



    if (isset($core['folderId']))

    {

    $folderId = $core['folderId'];

    }

    else

    {

    $folderId = $pubInfo['publication']['defaultFolder'];

    if ($pubInfo['publication']['defaultSubFolder'] != '')

    {

    $subFolder = $pubInfo['publication']['defaultSubFolder'];

    $subFolder = pagesetterExpandSubFolder($subFolder, $publication, $tid);



    $folderId = pnModApiFunc('folder', 'user', 'ensureFolder',

    array('parentId' => $folderId,

    'path' => $subFolder,

    'topicId' => $pubInfo['publication']['defaultFolderTopic']));

    if ($folderId === false)

    return pagesetterWFOperationError;

    }

    }



    if ($folderId != '' && $folderId != -1)

    {

    $ok = pnModApiFunc('folder', 'user', 'addItem',

    array('folderId' => $folderId,

    'module' => 'pagesetter',

    'type' => $pubInfo['publication']['filename'],

    'title' => $title,

    'key' => "$tid.$pid"));

    if ($ok === false)

    {

    $msg = pnModAPIFunc('folder', 'user', 'errorAPIGet');

    pagesetterErrorAPI(__FILE__, __LINE__, $msg);

    return pagesetterWFOperationError;

    }

    }

    }









    return $id !== false ? pagesetterWFOperationOk : pagesetterWFOperationError;

    }



    ?>










  • Posted: 08.02.2008, 16:23
     
    Converted
    rank:
    12
    registered:
     March 2009
    Status:
    offline
    last visit:
    Posts:
    0
    OK I have that working and it is look like that:
    first operation changeExpired

    Code

    <?php



    function pagesetter_operation_changeExpired(&$publication, &$core, &$args)

    {

    $online = (isset($args['ONLINE']) ? $args['ONLINE'] : 0);



    $publication['core_online'] = $online;



    $days = (isset($args['DAYS']) ? $args['DAYS'] : 30);



    $days = date('Y-m-d',mktime(0, 0, 0, date("m") , date("d")+ $days, date("Y")));





    $publication['core_expireDate'] = $days;









    $result = pnModAPIFunc( 'pagesetter',

    'edit',

    'createPub',

    array( 'tid' => $core['tid'],

    'pubData' => $publication) );

    if ($result === false)

    return pagesetterWFOperationError;



    $id = $core['id'] = $result['id'];



    // Inform Folder module of new publication

    // - place either in selected folder when called from folder module

    // or in default folder

    if (pnModAPILoad('folder', 'user'))

    {

    $tid = $result['tid'];

    $pid = $result['pid'];



    // Get complete publication info - not only what was edited.

    $publication = pnModAPIFunc( 'pagesetter', 'user', 'getPub',

    array('tid' => $tid,

    'id' => $id,

    'format' => 'user') );

    if ($publiation === false)

    return pagesetterWFOperationError;



    $pubInfo = pnModAPIFunc( 'pagesetter', 'admin', 'getPubTypeInfo',

    array('tid' => $tid) );

    if ($pubInfo === false)

    return pagesetterWFOperationError;



    $titleFieldId = $pubInfo['publication']['titleFieldID'];

    foreach ($pubInfo['fields'] as $field)

    if ($field['id'] == $titleFieldId)

    $title = $publication[$field['name']];



    if (isset($core['folderId']))

    {

    $folderId = $core['folderId'];

    }

    else

    {

    $folderId = $pubInfo['publication']['defaultFolder'];

    if ($pubInfo['publication']['defaultSubFolder'] != '')

    {

    $subFolder = $pubInfo['publication']['defaultSubFolder'];

    $subFolder = pagesetterExpandSubFolder($subFolder, $publication, $tid);



    $folderId = pnModApiFunc('folder', 'user', 'ensureFolder',

    array('parentId' => $folderId,

    'path' => $subFolder,

    'topicId' => $pubInfo['publication']['defaultFolderTopic']));

    if ($folderId === false)

    return pagesetterWFOperationError;

    }

    }



    if ($folderId != '' && $folderId != -1)

    {

    $ok = pnModApiFunc('folder', 'user', 'addItem',

    array('folderId' => $folderId,

    'module' => 'pagesetter',

    'type' => $pubInfo['publication']['filename'],

    'title' => $title,

    'key' => "$tid.$pid"));

    if ($ok === false)

    {

    $msg = pnModAPIFunc('folder', 'user', 'errorAPIGet');

    pagesetterErrorAPI(__FILE__, __LINE__, $msg);

    return pagesetterWFOperationError;

    }

    }

    }



    return $id !== false ? pagesetterWFOperationOk : pagesetterWFOperationError;

    }



    ?>



    Operation createNewRevisionWithDate

    Code

    <?php



    function pagesetter_operation_createNewRevisionWithDate(&$publication, &$core, &$args)

    {

    if (!isset($args['NEXTSTATE']))

    return;



    $nextState = $args['NEXTSTATE'];

    $online = (isset($args['ONLINE']) ? $args['ONLINE'] : 0);



    $tid = $core['tid'];

    $pid = $core['pid'];



    $publication['core_approvalState'] = $nextState;

    $publication['core_online'] = $online;





    $publication['core_publishDate'] = strftime("%Y-%m-%d %H:%M:%S", $publication['core_publishDate']);

    $publication['core_expireDate'] = strftime("%Y-%m-%d %H:%M:%S", $publication['core_expireDate']);





    $newInfo = pnModAPIFunc( 'pagesetter', 'edit', 'createNewRevision',

    array( 'tid' => $tid,

    'id' => $core['id'],

    'copyCreatedDate' => true,

    'pubData' => $publication) );



    if ($newInfo === false)

    return pagesetterWFOperationError;



    $ok = pnModAPIFunc('pagesetter', 'edit', 'updateOnlineStatus',

    array('tid' => $tid,

    'pid' => $pid,

    'id' => $newInfo['id'],

    'online' => $online));

    if ($ok === false)

    return pagesetterWFOperationError;



    $core['id'] = $newInfo['id'];



    // Inform Folder module of new publication

    if ($ok && $online && isset($core['folderId']) && pnModAPILoad('folder', 'user'))

    {

    $pubInfo = pnModAPIFunc( 'pagesetter', 'admin', 'getPubTypeInfo',

    array('tid' => $tid) );

    if ($pubInfo === false)

    return pagesetterWFOperationError;

    $titleFieldId = $pubInfo['publication']['titleFieldID'];

    foreach ($pubInfo['fields'] as $field)

    if ($field['id'] == $titleFieldId)

    $title = $publication[$field['name']];



    $ok = pnModApiFunc('folder', 'user', 'updateItem',

    array('itemId' => $core['folderId'],

    'title' => $title));

    if ($ok === false)

    return pagesetterWFOperationError;

    }



    return pagesetterWFOperationOk;

    }



    ?>


    Operation updateExpired

    Code

    <?php



    function pagesetter_operation_updateExpired(&$publication, &$core, &$args)

    {



    $days = (isset($args['DAYS']) ? $args['DAYS'] : 30);



    $days = date('Y-m-d',mktime(0, 0, 0, date("m") , date("d")+ $days, date("Y")));





    $publication['core_expireDate'] = $days;









    $ok = pnModAPIFunc( 'pagesetter',

    'edit',

    'updatePub',

    array( 'tid' => $core['tid'],

    'id' => $core['id'],

    'pubData' => $publication) );



    // Inform Folder module of updated publication

    if ($ok && isset($core['folderId']) && pnModAPILoad('folder', 'user'))

    {

    $tid = $core['tid'];



    $pubInfo = pnModAPIFunc( 'pagesetter', 'admin', 'getPubTypeInfo',

    array('tid' => $tid) );

    if ($pubInfo === false)

    return pagesetterWFOperationError;

    $titleFieldId = $pubInfo['publication']['titleFieldID'];

    foreach ($pubInfo['fields'] as $field)

    if ($field['id'] == $titleFieldId)

    $title = $publication[$field['name']];



    $ok = pnModApiFunc('folder', 'user', 'updateItem',

    array('itemId' => $core['folderId'],

    'title' => $title));

    if ($ok === false)

    return pagesetterWFOperationError;

    }



    return $ok ? pagesetterWFOperationOk : pagesetterWFOperationError;

    }



    ?>


    workflow

    Code

    <?xml version="1.0" encoding="ISO-8859-1"?>



    <workflow>



    <title>Ogloszenia</title>

    <description>Everything is online immediately after creation.</description>



    <configuration>



    <setting id="moderatorMails" title="Moderators mail addresses" type="text" height="100"/>

    <setting id="notificationText" title="Text on notification mails" type="text" height="100"/>

    <setting id="notificationSubject" title="Subject for notification mails" type="string"/>



    </configuration>







    <states>



    <state id="approved">

    <title>Zaakceptowany</title>

    <description>Content has been approved is available online</description>

    </state>



    <state id="deleted">

    <title>Skasowany</title>

    <description>Content has been deleted</description>

    </state>



    </states>





    <actions>



    <!-- From initial state -->



    <action id="submit">

    <title>Zapisz 3dni</title>

    <description>Save for 3 days </description>

    <permission>author</permission>

    <nextState>approved</nextState>

    <operation online="1" days="3">changeExpired</operation>



    </action>



    <action id="submit7">

    <title>Zapisz 7dni</title>

    <description>Save for 7 days </description>

    <permission>author</permission>

    <nextState>approved</nextState>

    <operation online="1" days="7">changeExpired</operation>



    </action>







    <!-- State: approved -->



    <action id="update">

    <title>Uaktualnij</title>

    <description>save changes</description>

    <permission>author and owner or editor</permission>

    <state>approved</state>



    <operation>moveToDepot</operation>

    <operation nextState="approved" online="1">createNewRevisionWithDate</operation>

    </action>





    <action id="p7">

    <title>Przed&#322;u&#380; 7dni</title>

    <description>extend 7 days</description>

    <permission>author and owner or editor</permission>

    <state>approved</state>



    <operation days="7">updateExpired</operation>

    </action>



    <action id="delete">

    <title>Usu&#324;</title>

    <description>Usu&#324; og&#322;oszenie</description>

    <permission>author and owner or editor</permission>

    <state>approved</state>



    <online>0</online>

    <operation nextState="deleted">moveToDepot</operation>

    <operation>deletePublication</operation>

    </action>



    </actions>





    </workflow>


    :-)

Template courtesy of Designs By Darren.