Exemplo n.º 1
0
 /**
  * Creates a list of favorites for the logged in user.
  *
  * @param $name the name of the list
  * @return int the identifier of the list
  */
 public function execute()
 {
     $ret = Api_Bo_Favorites::createList($this->name, $this->getAppId(), $this->getUserId());
     $response = array();
     $response['result'] = $ret === false ? '0' : $ret;
     return $response;
 }
Exemplo n.º 2
0
 /**
  * Sets the item as a favorite for the user.
  *
  * @param int $iid the item id.
  * @param int $lid optional - the list the favorite should be added to, otherwise the default list
  * @param int $alid optional - the list the favorite should be added to, otherwise the default list for the app
  */
 public function execute()
 {
     $ret = Api_Bo_Favorites::setFavorite($this->getAppId(), $this->getUserId(), $this->iid, $this->alid, $this->lid, $this->fbml);
     $response = array();
     $response['result'] = $ret === false ? '0' : '1';
     return $response;
 }
Exemplo n.º 3
0
 /**
  * Marks the favorite as Deleted
  *
  * @param int $iid
  * @param string $lid
  * @return Array
  */
 public function execute()
 {
     $ret = Api_Bo_Favorites::deleteFavorite($this->getAppId(), $this->getUserId(), $this->iid, $this->alid, $this->lid);
     $response = array();
     $response['result'] = $ret > 0 ? '1' : '0';
     return $response;
 }
Exemplo n.º 4
0
 /**
  * Gets the FBML description of the item that the user set.
  *
  * @param int $iid the item for which to retrieve the user's FBML description
  * @param array $uids optional - list of uids to retrieve FBML for, otherwise the logged in user
  * @param int $lid optional - the list to retrieve the FBML description for, otherwise the default list
  */
 public function execute()
 {
     $favs = Api_Bo_Favorites::getFBML($this->getAppId(), $this->item_id, $this->alid, $this->lid, $this->uids);
     $ret = array();
     if (count($favs > 0)) {
         foreach ($favs as $fav) {
             $ret['favorite'][] = array('uid' => $fav['user_id'], 'fbml' => $fav['fbml']);
         }
     }
     return $ret;
 }
Exemplo n.º 5
0
 /**
  * Checks whether the user (or users) has (have) marked this item as a favorite.
  *
  * @param string $iid the item to check
  * @param array $uids optional - the uids to check, otherwise the logged in user
  * @param int $lids optional - the array of lists to check, otherwise the default list
  *
  * @return array users who have the item marked favorite.
  */
 public function execute()
 {
     $users = Api_Bo_Favorites::getUsers($this->getAppId(), $this->iid, $this->alid, $this->lid, $this->uids);
     $retVal = array();
     if (count($users) > 0) {
         foreach ($users as $user) {
             $retVal['user'][] = $user['user_id'];
         }
     }
     return $retVal;
 }
Exemplo n.º 6
0
 /**
  * Gets the favorites lists for a given user or for the logged-in user.
  *
  * @param int $uid optional - the user for whom to get the lists. If not specified, the logged in user will be used.
  */
 public function execute()
 {
     $lists = Api_Bo_Favorites::getLists($this->uid, $this->getAppId());
     $retVal = array();
     if (count($lists) > 0) {
         $i = 0;
         foreach ($lists as $list) {
             $retVal['list'][$i++] = array('id' => $list['id'], 'name' => $list['name']);
         }
     }
     return $retVal;
 }
Exemplo n.º 7
0
 /**
  * Gets the favorite items for users.
  *
  * @param Array $uids the users for whom to retrieve favorite items, or the logged in user if not specified
  * @param int $lid optional - the list that is used to organize the favorites, or the default list if not specified
  * @param int $alid optional - the list that is used to organize the favorites for the app, otherwise the default list for the app
  *
  * @return unknown
  */
 public function execute()
 {
     $favs = Api_Bo_Favorites::getFavorites($this->getAppId(), $this->uids, $this->alid, $this->lid);
     $retVal = array();
     if (count($favs) > 0) {
         $retVal['favorite'] = array();
         $i = 0;
         foreach ($favs as $fav) {
             $retVal['favorite'][$i]['name'] = $fav['name'];
             $retVal['favorite'][$i]['iid'] = $fav['item_id'];
             $retVal['favorite'][$i]['uids'][] = $fav['user_id'];
             $retVal['favorite'][$i]['lid'] = $fav['list_id'];
             $retVal['favorite'][$i]['alid'] = $fav['app_list_id'];
             $i++;
         }
     }
     return $retVal;
 }
Exemplo n.º 8
0
 /**
  * Helper method to create a favorite
  *
  * @param unknown_type $app_id
  * @param unknown_type $uid
  * @param unknown_type $item_id
  * @param unknown_type $alid
  * @param unknown_type $lid
  */
 public static function createFavorite($app_id, $uid, $item_id, $alid, $lid)
 {
     return Api_Bo_Favorites::setFavorite($app_id, $uid, $item_id, $alid, $lid, '');
 }