<?php
/**
  * Ahead WebSoft Technologies Pvt Ltd.
  * @copyright  Copyright 2006-2026 Ahead WebSoft Technologies Pvt Ltd.
  * @license    https://www.socialengine.com/policies
*/
class Poke_Installer extends Engine_Package_Installer_Module {

  public function onInstall() {

    $db = $this->getDb();
    
    if($this->_databaseOperationType != 'upgrade') {
    
      $select = new Zend_Db_Select($db);
      $select->from('engine4_core_content', 'content_id')
              ->where('name = ?', 'left')
              ->where('page_id = ?', '5');
      $leftId = $select->query()->fetchColumn();
      if (!empty($leftId)) {
        $db->insert('engine4_core_content', array(
            'name' => 'poke.button',
            'page_id' => 5,
            'type' => 'widget',
            'params' => '{"title":"","showIconText":"1","nomobile":"0","name":"poke.button"}',
            'parent_content_id' => $leftId,
            'order' => 3,
        ));
        
        $db->insert('engine4_core_content', array(
            'name' => 'poke.back-button',
            'page_id' => 5,
            'type' => 'widget',
            'params' => '{"title":"","showType":"0","viewMore":"1","itemCount":"5","nomobile":"0","name":"poke.back-button"}',
            'parent_content_id' => $leftId,
            'order' => 4,
        ));
      }
      
      //Member Home Page
      $select = new Zend_Db_Select($db);
      $select->from('engine4_core_content', 'content_id')
              ->where('name = ?', 'right')
              ->where('page_id = ?', '4');
      $leftId = $select->query()->fetchColumn();
      if (!empty($leftId)) {
        $db->insert('engine4_core_content', array(
          'name' => 'poke.back-button',
          'page_id' => 4,
          'type' => 'widget',
          'params' => '{"title":"","showType":"0","viewMore":"1","itemCount":"5","nomobile":"0","name":"poke.back-button"}',
          'parent_content_id' => $leftId,
          'order' => 4,
        ));
      }
		}
		
    parent::onInstall();
  }
}
