You are here

api.html in Classified Ads 7.3

Same filename and directory in other branches
  1. 6.3 help/api.html

File

help/api.html
View source
<div class="classified-help">
  <h3>Module hooks</h3>
  <p>Classified Ads defines three notification hooks, which a module can 
    implement to notify users of the impending or occurred expiration or purge 
    of their ads.</p>
    
  <ul>
    <li><code>hook_classified_expire_alter(array $ads);</code> is invoked right
      after Classified Ads has expired a number of ads.</li>
    <li><code>hook_classified_notify_alter(array $ads, $kind);</code> is invoked
      when any ad has reached a given point in its life cycle. 
     <code>$kind</code> indicates which point this is.
      <ul>
        <li>half-life: the ads in the <code>$ads</code> array have only half of
          their lifetime remaining</li>
        <li>pre-expire: the ads in the <code>$ads</code> array will expire on
          the next day</li>
        <li>pre-purge; the ads in the <code>$ads</code> array will be purged 
          from the site on the next day</li>
        </ul> 
      </li>
    <li><code>hook_classified_purge_alter(array $ads);</code> is invoked right 
      after Classified Ads has purged a number of ads.</li>
    </ul>

  <p>For an implementation example, look into function 
  <code>classified_notifications_classified_purge_alter()</code> 
  in file <code>classsified_notification.module</code>.</p>
    
  <p>Note that, although these are "alter" hooks, modification of the 
    <code>$ads</code> array has no impact on the actions performed by Classified
    Ads: they will only affect other modules with a higher weight also 
    implementing the same hook.</p>
    
  <h3>Format of the <code>$ads</code> array</h3>
  <p>The three hooks receive an array in the same format:</p>
  
  <pre>
$data =  array(
  <em>uid1</em> => array(
    <em>nid11</em> => <em>title11</em>,
    <em>nid12</em> => <em>title12</em>,
    <em>nid...</em> => <em>title...</em>,
  ),
  <em>uid2</em> => array(
    <em>nid21</em> => <em>title21</em>,
    <em>nid22</em> => <em>title22</em>,
    <em>nid...</em> => <em>title...</em>,
  ),
  <em>uid...</em> => array(
    <em>nid...</em> => <em>title...</em>,
  ),
);  
    </pre>  
  </div>