public static function getOneUserApp($appId, $userId) { $id = Api_Dao_UsersApp::createUsersApp($appId, $userId); return Api_Dao_UsersApp::getUserAppById($id); }
/** * Enter description here... * * @param unknown_type $uid * @param unknown_type $appId * @param unknown_type $type * @param unknown_type $templatized * @param unknown_type $author * @param unknown_type $title * @param unknown_type $body * @param unknown_type $image1 * @param unknown_type $image1Link * @param unknown_type $image2 * @param unknown_type $image2Link * @param unknown_type $image3 * @param unknown_type $image3Link * @param unknown_type $image4 * @param unknown_type $image4Link * @param unknown_type $titleData * @param unknown_type $bodyData * @param unknown_type $bodyGeneral * @param unknown_type $priority * @param unknown_type $targets * @param unknown_type $actor * @return unknown */ public static function createTemplatizedFeed($uid, $appId, $type, $templatized, $author, $title, $body, $image1, $image1Link, $image2, $image2Link, $image3, $image3Link, $image4, $image4Link, $titleData, $bodyData, $bodyGeneral, $priority, $targets, $actor) { if (null == $priority || strlen($priority) == 0) { $priority = 0; } if ($actor == null) { $actor = $uid; } else { // The ACTOR must be (a) friend (b) have app if (!Api_Dao_Friends::friendCheck($uid, $actor)) { throw new Exception(FB_ERROR_MSG_ACTOR_USER_NOT_FRIENDS, FB_ERROR_CODE_REQUIRES_PERMISSION); } if (!Api_Dao_UsersApp::isUsersApp($appId, $actor)) { throw new Exception(FB_ERROR_MSG_ACTOR_USER_DONT_SHAREAPPS, FB_ERROR_CODE_REQUIRES_PERMISSION); } } if ($targets != null) { // All targets must be frinds of acting user. $friends = Api_Dao_Friends::friendsGetFriends($actor); $targets = explode(",", $targets); $intersect = array_intersect($friends, $targets); if (count($targets) != count($intersect)) { throw new Exception(FB_ERROR_MSG_TARGETS_NOT_FRIENDS, FB_ERROR_CODE_REQUIRES_PERMISSION); } } // Validate title data, actor token must exist. $titleTokens = self::get_tokens($title); // error_log( 'title tokens: ' . var_export( $titleTokens, true ) ); $countTest = 1; if (!in_array("actor", $titleTokens)) { throw new Exception(FB_ERROR_MSG_FEED_MISSING_ACTOR, FB_ERROR_CODE_FEED_TITLE_PARAMS); } if (in_array("target", $titleTokens)) { if ($targets == null) { throw new Exception(FB_ERROR_MSG_FEED_MISSING_TARGETS, FB_ERROR_CODE_FEED_TITLE_PARAMS); } $countTest = 2; } if (count($titleTokens) > $countTest) { if ($titleData == null || empty($titleData)) { throw new Exception(FB_ERROR_MSG_FEED_TITLE_JSON_EMPTY, FB_ERROR_CODE_FEED_TITLE_JSON); } // check all tokens in string are in data $titleDataTokens = json_decode($titleData, true); // error_log( 'title data tokens: ' . var_export( $titleDataTokens, true ) ); if (array_key_exists('actor', $titleDataTokens) || array_key_exists('target', $titleDataTokens)) { throw new Exception(FB_ERROR_MSG_FEED_TITLE_JSON_INVALID, FB_ERROR_CODE_FEED_TITLE_JSON); } foreach ($titleTokens as $token) { // error_log( 'title token: ' . $token ); if ($token != 'target' && $token != 'actor' && !array_key_exists($token, $titleDataTokens)) { throw new Exception(FB_ERROR_MSG_FEED_MISSING_PARAMS, FB_ERROR_CODE_FEED_TITLE_PARAMS); } } } else { $titleData = null; } // Validate body data $bodyTokens = self::get_tokens($body); $countTest = 0; if (in_array("actor", $bodyTokens)) { $countTest++; } if (in_array("target", $bodyTokens)) { if ($targets == null) { throw new Exception(FB_ERROR_MSG_FEED_BODY_MISSING_TARGETS, FB_ERROR_CODE_FEED_BODY_PARAMS); } $countTest++; } if (count($bodyTokens) > $countTest) { if ($bodyData == null || empty($bodyData)) { throw new Exception(FB_ERROR_MSG_FEED_BODY_JSON_EMPTY, FB_ERROR_CODE_FEED_BODY_JSON); } $bodyDataTokens = json_decode($bodyData, true); if (array_key_exists('actor', $bodyDataTokens) || array_key_exists('target', $bodyDataTokens)) { throw new Exception(FB_ERROR_MSG_FEED_BODY_JSON_INVALID, FB_ERROR_CODE_FEED_BODY_JSON); } foreach ($bodyTokens as $token) { if ($token != 'target' && $token != 'actor' && !array_key_exists($token, $bodyDataTokens)) { throw new Exception(FB_ERROR_MSG_FEED_BODY_MISSING_PARAMS, FB_ERROR_CODE_FEED_BODY_PARAMS); } } } else { $bodyData = null; } return Api_Dao_Feed::createFeed($type, $templatized, $title, $titleData, $body, $bodyData, $bodyGeneral, $author, $image1, $image1Link, $image2, $image2Link, $image3, $image3Link, $image4, $image4Link, $actor, $targets, $priority); }
/** * Enter description here... * * @param unknown_type $userId * @param unknown_type $appId * @param unknown_type $api_key * @param unknown_type $status * @param unknown_type $cleared * @return unknown */ public static function setStatus($userId, $appId, $api_key, $networkId, $status, $cleared) { $hasPermissionResult = Api_Dao_UsersApp::checkUserHasPermission($api_key, $userId, 'status_update', $networkId); if ($hasPermissionResult != true) { throw new Exception(FB_ERROR_MSG_REQUIRES_PERMISSION, FB_ERROR_CODE_REQUIRES_PERMISSION); } $ret = false; if (Api_Dao_User::isStatus($userId, $appId)) { $ret = Api_Dao_User::updateStatus($userId, $appId, $status); } else { $ret = Api_Dao_User::createStatus($userId, $appId, $status); } Api_Dao_User::createStatusHistory($userId, $appId, $status, $cleared); return $ret; }
private function deleteUserAndApp($id, $app) { try { Api_Dao_UsersApp::deleteUserApp($id); } catch (Exception $exception) { // nothing on purpose } try { Api_Dao_App::deleteApp($app); } catch (Exception $exception) { // nothing on purpose } }
/** * Enter description here... * * @param unknown_type $userId * @param unknown_type $appId * @param unknown_type $fbml */ public static function setFBML($userId, $appId, $fbml) { $userApps = Api_Dao_UsersApp::getUserAppByAppIdAndUserId($userId, $appId); if (count($userApps) > 0) { $userApp = $userApps[0]; $userApp->fbml = $fbml; $ret = $userApp->trySave(); if ($ret) { return true; } return false; } else { return Api_Dao_UsersApp::createUsersApp($appId, $userId, 0, 0, 0, 0, 0, 0, 0, 'wide', 0, $fbml); } }