Exemplo n.º 1
0
 /**
  * main action
  */
 public function mainAction()
 {
     $data = array();
     $data['customer_id'] = (int) $_SESSION['client']['customer']['id'];
     // mandatory
     $data['node_id'] = $this->GET['node_id'];
     // mandatory
     if (!empty($this->GET['action_id'])) {
         $data['action_id'] = $this->GET['action_id'];
     }
     if (!empty($this->GET['network'])) {
         $data['network'] = $this->GET['network'];
     }
     $data['action_name'] = $this->GET['action_name'];
     // mandatory
     if (!empty($this->GET['object_name'])) {
         $data['object_name'] = $this->GET['object_name'];
     }
     $ClientAction = new client_action();
     if ($ClientAction->insertAction($data)) {
         msg("Action inserted to the database", "ok", 1);
     } else {
         msg("Unable to insert action to database, missing parameters " . print_r($data, true), "error", 1);
     }
     return true;
 }
Exemplo n.º 2
0
 /**
  * main action
  */
 public function mainAction()
 {
     $this->customer_id = (int) $_SESSION['client']['customer']['id'];
     if (is_numeric($this->GET['node_id']) && !empty($this->GET['action_id']) && !empty($this->GET['network']) && !empty($this->GET['action_name']) && !empty($this->GET['object_name']) && $this->customer_id > 0) {
         $Actions = new client_action();
         $Actions->insert(array('customer_id' => $this->customer_id, 'node_id' => $this->GET['node_id'], 'action_id' => $this->GET['action_id'], 'network' => $this->GET['network'], 'action_name' => $this->GET['action_name'], 'object_name' => $this->GET['object_name'], 'created' => date("c"), 'modified' => date("c"), 'other_data' => null));
         msg("Action inserted to the database", "ok", 1);
     } else {
         msg("Unable to insert action to database, missing parameters " . print_r($this->GET, true), "error", 1);
     }
     return true;
 }
Exemplo n.º 3
0
 public function insertComment($data, $options = false)
 {
     $result = parent::insertComment($data, $options);
     if ($result && client_action::hasOpenGraphStory('comment_on', 'recipe')) {
         $request = new Onxshop_Request("component/client/facebook_story_create~" . "action=comment_on" . ":object=recipe" . ":node_id=" . $_SESSION['active_pages'][0] . "~");
     }
     return $result;
 }
Exemplo n.º 4
0
 /**
  * saveClientAction
  */
 public function saveClientAction($node_id, $network)
 {
     if (!is_numeric($node_id)) {
         return false;
     }
     require_once 'models/client/client_action.php';
     $ClientAction = new client_action();
     $data = array();
     $data['customer_id'] = (int) $_SESSION['client']['customer']['id'];
     $data['node_id'] = $node_id;
     if ($network) {
         $data['network'] = $network;
     }
     $data['action_name'] = 'share_intention';
     if ($inserted_id = $ClientAction->insertAction($data)) {
         return $inserted_id;
     } else {
         msg("Cannot save share action initiated from share_counter", 'error', 1);
     }
 }
Exemplo n.º 5
0
 protected function createFacebookStory()
 {
     if (client_action::hasOpenGraphStory('enter', 'competition')) {
         $request = new Onxshop_Request("component/client/facebook_story_create~" . "action=vote_in" . ":object=poll" . ":node_id=" . $_SESSION['active_pages'][0] . "~");
     }
 }
Exemplo n.º 6
0
 /**
  * Get list of actions performed by given customers from local database
  * 
  * @param  array $customer_ids Customers id to query
  * @return Array of client_action
  */
 protected function getActionsForCustomers($customer_ids, $num_displayed_items = 3, $filter = false)
 {
     $result = array();
     if (is_array($customer_ids) && count($customer_ids) > 0 && ($ids = $this->prepareListForSql($customer_ids))) {
         $Action = new client_action();
         $filter_sql = '';
         if (is_array($filter) && count($filter) > 0) {
             $filter_sql = ' AND (';
             foreach ($filter as $action) {
                 $action = explode("-", $action);
                 if (count($action) == 2) {
                     $filter_sql .= "(action_name = '" . pg_escape_string($action[0]) . "'";
                     $filter_sql .= " AND object_name = '" . pg_escape_string($action[1]) . "') OR ";
                 }
             }
             $filter_sql .= '(1 = 0))';
         }
         $list = $Action->listing("network = 'facebook' AND customer_id IN ({$ids}) {$filter_sql}", "id DESC", "0,{$num_displayed_items}");
         if (is_array($list) && count($list) > 0) {
             foreach ($list as $item) {
                 $result[] = $item;
             }
         }
     }
     return $result;
 }