本文整理汇总了PHP中Subscription::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Subscription::find方法的具体用法?PHP Subscription::find怎么用?PHP Subscription::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Subscription
的用法示例。
在下文中一共展示了Subscription::find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: destroy
function destroy($args, $apidata)
{
parent::handle($args);
if (!in_array($_SERVER['REQUEST_METHOD'], array('POST', 'DELETE'))) {
$this->clientError(_('This method requires a POST or DELETE.'), 400, $apidata['content-type']);
return;
}
$id = $apidata['api_arg'];
# We can't subscribe to a remote person, but we can unsub
$other = $this->get_profile($id);
$user = $apidata['user'];
$sub = new Subscription();
$sub->subscriber = $user->id;
$sub->subscribed = $other->id;
if ($sub->find(true)) {
$sub->query('BEGIN');
$sub->delete();
$sub->query('COMMIT');
} else {
$this->clientError(_('You are not friends with the specified user.'), 403, $apidata['content-type']);
return;
}
$type = $apidata['content-type'];
$this->init_document($type);
$this->show_profile($other, $type);
$this->end_document($type);
}
示例2: dataExist
private function dataExist($id)
{
$data = Subscription::find($id);
if (!$data) {
return Redirect::route('subscription_list')->with('mError', 'Cet abonnement est introuvable !');
} else {
return $data;
}
}
示例3: getSubscribers
function getSubscribers()
{
$subs = array();
$sub = new Subscription();
$sub->subscribed = $this->user->id;
if ($sub->find()) {
while ($sub->fetch()) {
if ($sub->subscriber != $this->user->id) {
$subs[] = clone $sub;
}
}
}
return $subs;
}
示例4: view
function view($id = FALSE)
{
$this->view_data['submenu'] = array($this->lang->line('application_back') => 'subscriptions');
$this->view_data['subscription'] = Subscription::find($id);
$this->view_data['items'] = SubscriptionHasItem::find('all', array('conditions' => array('subscription_id=?', $id)));
if ($this->view_data['subscription']->company_id != $this->client->company->id) {
redirect('csubscriptions');
}
$datediff = strtotime($this->view_data['subscription']->end_date) - strtotime($this->view_data['subscription']->issue_date);
$timespan = floor($datediff / (60 * 60 * 24));
switch ($this->view_data['subscription']->frequency) {
case '+7 day':
$this->view_data['run_time'] = round($timespan / 7);
$this->view_data['p3'] = "1";
$this->view_data['t3'] = "W";
break;
case '+14 day':
$this->view_data['run_time'] = round($timespan / 14);
$this->view_data['p3'] = "2";
$this->view_data['t3'] = "W";
break;
case '+1 month':
$this->view_data['run_time'] = round($timespan / 30);
$this->view_data['p3'] = "1";
$this->view_data['t3'] = "M";
break;
case '+3 month':
$this->view_data['run_time'] = round($timespan / 90);
$this->view_data['p3'] = "3";
$this->view_data['t3'] = "M";
break;
case '+6 month':
$this->view_data['run_time'] = round($timespan / 182);
$this->view_data['p3'] = "6";
$this->view_data['t3'] = "M";
break;
case '+1 year':
$this->view_data['run_time'] = round($timespan / 365);
$this->view_data['p3'] = "1";
$this->view_data['t3'] = "Y";
break;
}
$this->content_view = 'subscriptions/client_views/view';
}
示例5: Subscription
function count_subscriptions($profile)
{
$count = 0;
$sub = new Subscription();
$sub->subscribed = $profile->id;
$count = $sub->find();
if ($count > 0) {
return $count - 1;
} else {
return 0;
}
}
示例6: validateOmb
function validateOmb()
{
$listener = $_GET['omb_listener'];
$listenee = $_GET['omb_listenee'];
$nickname = $_GET['omb_listenee_nickname'];
$profile = $_GET['omb_listenee_profile'];
$user = User::staticGet('uri', $listener);
if (!$user) {
// TRANS: Exception thrown when no valid user is found for an authorisation request.
// TRANS: %s is a listener URI.
throw new Exception(sprintf(_('Listener URI "%s" not found here.'), $listener));
}
if (strlen($listenee) > 255) {
// TRANS: Exception thrown when listenee URI is too long for an authorisation request.
// TRANS: %s is a listenee URI.
throw new Exception(sprintf(_('Listenee URI "%s" is too long.'), $listenee));
}
$other = User::staticGet('uri', $listenee);
if ($other) {
// TRANS: Exception thrown when listenee URI is a local user for an authorisation request.
// TRANS: %s is a listenee URI.
throw new Exception(sprintf(_('Listenee URI "%s" is a local user.'), $listenee));
}
$remote = Remote_profile::staticGet('uri', $listenee);
if ($remote) {
$sub = new Subscription();
$sub->subscriber = $user->id;
$sub->subscribed = $remote->id;
if ($sub->find(true)) {
// TRANS: Exception thrown when already subscribed.
throw new Exception('You are already subscribed to this user.');
}
}
if ($profile == common_profile_url($nickname)) {
// TRANS: Exception thrown when profile URL is a local user for an authorisation request.
// TRANS: %s is a profile URL.
throw new Exception(sprintf(_('Profile URL "%s" is for a local user.'), $profile));
}
$license = $_GET['omb_listenee_license'];
$site_license = common_config('license', 'url');
if (!common_compatible_license($license, $site_license)) {
// TRANS: Exception thrown when licenses are not compatible for an authorisation request.
// TRANS: %1$s is the license for the listenee, %2$s is the license for "this" StatusNet site.
throw new Exception(sprintf(_('Listenee stream license "%1$s" is not ' . 'compatible with site license "%2$s".'), $license, $site_license));
}
$avatar = $_GET['omb_listenee_avatar'];
if ($avatar) {
if (!common_valid_http_url($avatar) || strlen($avatar) > 255) {
// TRANS: Exception thrown when avatar URL is invalid for an authorisation request.
// TRANS: %s is an avatar URL.
throw new Exception(sprintf(_('Avatar URL "%s" is not valid.'), $avatar));
}
$size = @getimagesize($avatar);
if (!$size) {
// TRANS: Exception thrown when avatar URL could not be read for an authorisation request.
// TRANS: %s is an avatar URL.
throw new Exception(sprintf(_('Cannot read avatar URL "%s".'), $avatar));
}
if (!in_array($size[2], array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG))) {
// TRANS: Exception thrown when avatar URL return an invalid image type for an authorisation request.
// TRANS: %s is an avatar URL.
throw new Exception(sprintf(_('Wrong image type for avatar URL ' . '"%s".'), $avatar));
}
}
}
示例7: handle
function handle($args)
{
parent::handle($args);
header('Content-Type: application/rdf+xml');
$this->startXML();
$this->elementStart('rdf:RDF', array('xmlns:rdf' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'xmlns:rdfs' => 'http://www.w3.org/2000/01/rdf-schema#', 'xmlns:geo' => 'http://www.w3.org/2003/01/geo/wgs84_pos#', 'xmlns' => 'http://xmlns.com/foaf/0.1/'));
// This is the document about the user
$this->showPpd('', $this->user->uri);
// XXX: might not be a person
$this->elementStart('Person', array('rdf:about' => $this->user->uri));
$this->element('mbox_sha1sum', null, sha1('mailto:' . $this->user->email));
if ($this->profile->fullname) {
$this->element('name', null, $this->profile->fullname);
}
if ($this->profile->homepage) {
$this->element('homepage', array('rdf:resource' => $this->profile->homepage));
}
if ($this->profile->bio) {
$this->element('rdfs:comment', null, $this->profile->bio);
}
// XXX: more structured location data
if ($this->profile->location) {
$this->elementStart('based_near');
$this->elementStart('geo:SpatialThing');
$this->element('name', null, $this->profile->location);
$this->elementEnd('geo:SpatialThing');
$this->elementEnd('based_near');
}
$this->showMicrobloggingAccount($this->profile, common_root_url());
$avatar = $this->profile->getOriginalAvatar();
if ($avatar) {
$this->elementStart('img');
$this->elementStart('Image', array('rdf:about' => $avatar->url));
foreach (array(AVATAR_PROFILE_SIZE, AVATAR_STREAM_SIZE, AVATAR_MINI_SIZE) as $size) {
$scaled = $this->profile->getAvatar($size);
if (!$scaled->original) {
// sometimes the original has one of our scaled sizes
$this->elementStart('thumbnail');
$this->element('Image', array('rdf:about' => $scaled->url));
$this->elementEnd('thumbnail');
}
}
$this->elementEnd('Image');
$this->elementEnd('img');
}
// Get people user is subscribed to
$person = array();
$sub = new Subscription();
$sub->subscriber = $this->profile->id;
$sub->whereAdd('subscriber != subscribed');
if ($sub->find()) {
while ($sub->fetch()) {
if ($sub->token) {
$other = Remote_profile::staticGet('id', $sub->subscribed);
} else {
$other = User::staticGet('id', $sub->subscribed);
}
if (!$other) {
common_debug('Got a bad subscription: ' . print_r($sub, true));
continue;
}
$this->element('knows', array('rdf:resource' => $other->uri));
$person[$other->uri] = array(LISTENEE, $other);
}
}
// Get people who subscribe to user
$sub = new Subscription();
$sub->subscribed = $this->profile->id;
$sub->whereAdd('subscriber != subscribed');
if ($sub->find()) {
while ($sub->fetch()) {
if ($sub->token) {
$other = Remote_profile::staticGet('id', $sub->subscriber);
} else {
$other = User::staticGet('id', $sub->subscriber);
}
if (!$other) {
common_debug('Got a bad subscription: ' . print_r($sub, true));
continue;
}
if (array_key_exists($other->uri, $person)) {
$person[$other->uri][0] = BOTH;
} else {
$person[$other->uri] = array(LISTENER, $other);
}
}
}
$this->elementEnd('Person');
foreach ($person as $uri => $p) {
$foaf_url = null;
if ($p[1] instanceof User) {
$foaf_url = common_local_url('foaf', array('nickname' => $p[1]->nickname));
}
$this->profile = Profile::staticGet($p[1]->id);
$this->elementStart('Person', array('rdf:about' => $uri));
if ($p[0] == LISTENER || $p[0] == BOTH) {
$this->element('knows', array('rdf:resource' => $this->user->uri));
}
$this->showMicrobloggingAccount($this->profile, $p[1] instanceof User ? common_root_url() : null);
if ($foaf_url) {
//.........这里部分代码省略.........
示例8: function
<?php
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the Closure to execute when that URI is requested.
|
*/
Route::get('/pdf', function () {
$data['user'] = User::find(11);
$data['subscription'] = Subscription::find(10);
$data['payment'] = Payment::find(34);
//$pdf = PDF::loadView('docs.faktura', $data);
return View::make('docs.faktura', $data);
//return $pdf->stream();
});
//sitewide
Route::get('/', array('uses' => 'HomeController@showHome'));
Route::get('/informacje', array('uses' => 'HomeController@showAboutUs'));
//Route::get('/faq', array('uses' =>'HomeController@showFaq'));
Route::get('/kontakt', array('uses' => 'HomeController@showContact'));
Route::get('/regulamin', array('uses' => 'HomeController@showLegal'));
//Route::get('/oferta', array('uses' =>'HomeController@showPricing'));
Route::post('/contact/send', array('uses' => 'HomeController@postContactForm'));
Route::get('/robots.txt', array('uses' => 'HomeController@generateRobots'));
Route::get('/sitemap.xml', array('uses' => 'HomeController@generateSitemap'));
// auth
示例9: _getNthSub
/**
* Get the Nth most recent subscription for this user
*
* @param User $user The user to get subscriptions for
* @param integer $n How far to count back
*
* @return Subscription a subscription or null
*/
private function _getNthSub($user, $n)
{
$sub = new Subscription();
$sub->subscriber = $user->id;
$sub->orderBy('created DESC');
$sub->limit($n - 1, 1);
if ($sub->find(true)) {
return $sub;
} else {
return null;
}
}
示例10: getSubscribers
function getSubscribers()
{
$subs = array();
$sub = new Subscription();
$sub->subscribed = $this->user->id;
if (!empty($this->after)) {
$sub->whereAdd("created > '" . common_sql_date($this->after) . "'");
}
if ($sub->find()) {
while ($sub->fetch()) {
if ($sub->subscriber != $this->user->id) {
$subs[] = clone $sub;
}
}
}
return $subs;
}
示例11: Subscription
function _deleteSubscriptions()
{
$sub = new Subscription();
$sub->subscriber = $this->getID();
$sub->find();
while ($sub->fetch()) {
try {
$other = $sub->getSubscribed();
if (!$other->sameAs($this)) {
Subscription::cancel($this, $other);
}
} catch (NoResultException $e) {
// Profile not found
common_log(LOG_INFO, 'Subscribed profile id==' . $sub->subscribed . ' not found when deleting profile id==' . $this->getID() . ', ignoring...');
} catch (ServerException $e) {
// Subscription cancel failed
common_log(LOG_INFO, 'Subscribed profile id==' . $other->getID() . ' could not be reached for unsubscription notice when deleting profile id==' . $this->getID() . ', ignoring...');
}
}
$sub = new Subscription();
$sub->subscribed = $this->getID();
$sub->find();
while ($sub->fetch()) {
try {
$other = $sub->getSubscriber();
common_log(LOG_INFO, 'Subscriber profile id==' . $sub->subscribed . ' not found when deleting profile id==' . $this->getID() . ', ignoring...');
if (!$other->sameAs($this)) {
Subscription::cancel($other, $this);
}
} catch (NoResultException $e) {
// Profile not found
common_log(LOG_INFO, 'Subscribed profile id==' . $sub->subscribed . ' not found when deleting profile id==' . $this->getID() . ', ignoring...');
} catch (ServerException $e) {
// Subscription cancel failed
common_log(LOG_INFO, 'Subscriber profile id==' . $other->getID() . ' could not be reached for unsubscription notice when deleting profile id==' . $this->getID() . ', ignoring...');
}
}
// Finally delete self-subscription
$self = new Subscription();
$self->subscriber = $this->getID();
$self->subscribed = $this->getID();
$self->delete();
}
示例12: index
function index()
{
$this->theme_view = 'blank';
$this->load->helper(array('dompdf', 'file'));
$timestamp = time();
$core_settings = Setting::first();
$date = date("Y-m-d");
if ($core_settings->cronjob == "1" && time() > $core_settings->last_cronjob + 300) {
$core_settings->last_cronjob = time();
$core_settings->save();
$this->load->database();
//Check Subscriptions
$sql = 'SELECT * FROM subscriptions WHERE status != "Inactive" AND end_date > "' . $date . '" AND "' . $date . '" >= next_payment ORDER BY next_payment';
$res = $this->db->query($sql);
$res = $res->result();
foreach ($res as $key2 => $value2) {
$eventline = 'New invoice created for subscription <a href="' . base_url() . 'subscriptions/view/' . $value2->id . '">#' . $value2->reference . '</a>';
$subscription = Subscription::find($value2->id);
$invoice = Invoice::last();
$invoice_reference = Setting::first();
if ($subscription) {
$_POST['subscription_id'] = $subscription->id;
$_POST['company_id'] = $subscription->company_id;
if ($subscription->subscribed != 0) {
$_POST['status'] = "Paid";
} else {
$_POST['status'] = "Open";
}
$_POST['currency'] = $subscription->currency;
$_POST['issue_date'] = $subscription->next_payment;
$_POST['due_date'] = date('Y-m-d', strtotime('+3 day', strtotime($subscription->next_payment)));
$_POST['currency'] = $subscription->currency;
$_POST['terms'] = $subscription->terms;
$_POST['discount'] = $subscription->discount;
$_POST['reference'] = $invoice_reference->invoice_reference;
$invoice = Invoice::create($_POST);
$invoiceid = Invoice::last();
$items = SubscriptionHasItem::find('all', array('conditions' => array('subscription_id=?', $value2->id)));
foreach ($items as $value) {
$itemvalues = array('invoice_id' => $invoiceid->id, 'item_id' => $value->item_id, 'amount' => $value->amount, 'description' => $value->description, 'value' => $value->value, 'name' => $value->name, 'type' => $value->type);
InvoiceHasItem::create($itemvalues);
}
$invoice_reference->update_attributes(array('invoice_reference' => $invoice_reference->invoice_reference + 1));
if ($invoice) {
$subscription->next_payment = date('Y-m-d', strtotime($subscription->frequency, strtotime($subscription->next_payment)));
$subscription->save();
//Send Invoice to Client via email
$this->load->library('parser');
$data["invoice"] = Invoice::find($invoiceid->id);
$data['items'] = InvoiceHasItem::find('all', array('conditions' => array('invoice_id=?', $invoiceid->id)));
$data["core_settings"] = Setting::first();
// Generate PDF
$html = $this->load->view($data["core_settings"]->template . '/' . 'invoices/preview', $data, true);
$filename = $this->lang->line('application_invoice') . '_' . $data["invoice"]->reference;
pdf_create($html, $filename, FALSE);
//email
$this->email->from($data["core_settings"]->email, $data["core_settings"]->company);
$this->email->to($data["invoice"]->company->client->email);
$this->email->subject($data["core_settings"]->invoice_mail_subject);
$this->email->attach("files/temp/" . $filename . ".pdf");
$due_date = date($data["core_settings"]->date_format, human_to_unix($data["invoice"]->due_date . ' 00:00:00'));
//Set parse values
$parse_data = array('client_contact' => $data["invoice"]->company->client->firstname . ' ' . $data["invoice"]->company->client->lastname, 'due_date' => $due_date, 'invoice_id' => $data["invoice"]->reference, 'client_link' => $data["core_settings"]->domain, 'company' => $data["core_settings"]->company, 'logo' => '<img src="' . base_url() . '' . $data["core_settings"]->logo . '" alt="' . $data["core_settings"]->company . '"/>', 'invoice_logo' => '<img src="' . base_url() . '' . $data["core_settings"]->invoice_logo . '" alt="' . $data["core_settings"]->company . '"/>');
$email_invoice = read_file('./application/views/' . $data["core_settings"]->template . '/templates/email_invoice.html');
$message = $this->parser->parse_string($email_invoice, $parse_data);
$this->email->message($message);
if ($this->email->send()) {
$data["invoice"]->update_attributes(array('status' => 'Sent', 'sent_date' => date("Y-m-d")));
}
log_message('error', $eventline);
unlink("files/temp/" . $filename . ".pdf");
}
}
}
//Check Subscriptions end
// Auto Backup every 7 days
if ($core_settings->autobackup == "1" && time() > $core_settings->last_autobackup + 7 * 24 * 60 * 60) {
$this->load->dbutil();
$prefs = array('format' => 'zip', 'filename' => 'Database-auto-full-backup_' . date('Y-m-d_H-i'));
$backup =& $this->dbutil->backup($prefs);
if (!write_file('./files/backup/Database-auto-full-backup_' . date('Y-m-d_H-i') . '.zip', $backup)) {
log_message('error', "Error while creating auto database backup!");
} else {
$core_settings->last_autobackup = time();
$core_settings->save();
log_message('error', "Auto backup has been created.");
}
}
echo "Success";
}
}
示例13: omb_broadcast_profile
function omb_broadcast_profile($profile)
{
# First, get remote users subscribed to this profile
# XXX: use a join here rather than looping through results
$sub = new Subscription();
$sub->subscribed = $profile->id;
if ($sub->find()) {
$updated = array();
while ($sub->fetch()) {
$rp = Remote_profile::staticGet('id', $sub->subscriber);
if ($rp) {
if (!array_key_exists($rp->updateprofileurl, $updated)) {
if (omb_update_profile($profile, $rp, $sub)) {
$updated[$rp->updateprofileurl] = true;
}
}
}
}
}
}
示例14: postNieuwsbrievenSubscriptionData
/**
* [postRenewalSubscriptionData]
* @return [json] [DT compatible object]
*/
public function postNieuwsbrievenSubscriptionData()
{
$posted_values = $_POST['data']['subscriptions'];
$posted_p = var_export($_POST, true);
error_log($posted_p);
//error_log($posted_ndx);
$curr_company = Company::find((int) $posted_values["company_id"]);
$subscription = Subscription::find((int) $posted_values["id"]);
$curr_aws_account = $posted_values["aws_auth"];
if ($curr_company && $subscription) {
$aws_auth = CompanyMeta::firstOrNew(['company_id' => $curr_company->id, 'type' => 'aws', 'subtype' => 'auth', 'key' => 'account']);
$aws_auth->value = $curr_aws_account;
$aws_auth->save();
// load relations
$load_curr_company = $subscription->company;
$load_curr_service = $subscription->service;
$load_curr_category = $subscription->service->category;
$load_curr_status = $subscription->status;
$load_curr_period = $subscription->period;
$curr_company = $subscription->company !== NULL ? (object) ['id' => $subscription->company_id, 'bedrijfsnaam' => utf8_encode($subscription->company->bedrijfsnaam)] : (object) null;
$curr_service = $subscription->service !== NULL ? (object) ['id' => $subscription->service_id, 'category_id' => $subscription->category_id, 'name' => utf8_encode($subscription->service->name)] : (object) null;
$curr_category = $subscription->service->category !== NULL ? (object) ['id' => $subscription->service->category_id, 'name' => utf8_encode($subscription->service->category->name)] : (object) null;
$curr_status = $subscription->status !== NULL ? (object) ['id' => $subscription->status_id, 'description' => utf8_encode($subscription->status->description)] : (object) null;
$curr_period = $subscription->period !== NULL ? (object) ['id' => $subscription->invoice_periods_id, 'description' => utf8_encode($subscription->period->description)] : (object) null;
$data = (object) ['DT_RowId' => 'row_' . $subscription->id, 'subscriptions' => $subscription, 'companies' => $curr_company, 'service_categories' => $curr_category, 'services' => $curr_service, 'statuses' => $curr_status, 'invoice_periods' => $curr_period];
$ret = ['row' => $data, 'companies' => $this->getAllCompanies(), 'services' => $this->getAllServices(), 'service_categories' => $this->getAllServiceCategories(), 'statuses' => $this->getAllStatuses(), 'invoice_periods' => $this->getAllInvoicePeriods()];
return Response::json($ret);
}
return Response::json((object) null);
}
示例15: Subscription
function update_profile($req, $consumer, $token)
{
$version = $req->get_parameter('omb_version');
if ($version != OMB_VERSION_01) {
$this->clientError(_('Unsupported OMB version'), 400);
return false;
}
# First, check to see if listenee exists
$listenee = $req->get_parameter('omb_listenee');
$remote = Remote_profile::staticGet('uri', $listenee);
if (!$remote) {
$this->clientError(_('Profile unknown'), 404);
return false;
}
# Second, check to see if they should be able to post updates!
# We see if there are any subscriptions to that remote user with
# the given token.
$sub = new Subscription();
$sub->subscribed = $remote->id;
$sub->token = $token->key;
if (!$sub->find(true)) {
$this->clientError(_('You did not send us that profile'), 403);
return false;
}
$profile = Profile::staticGet('id', $remote->id);
if (!$profile) {
# This one is our fault
$this->serverError(_('Remote profile with no matching profile'), 500);
return false;
}
$nickname = $req->get_parameter('omb_listenee_nickname');
if ($nickname && !Validate::string($nickname, array('min_length' => 1, 'max_length' => 64, 'format' => VALIDATE_NUM . VALIDATE_ALPHA_LOWER))) {
$this->clientError(_('Nickname must have only lowercase letters and numbers and no spaces.'));
return false;
}
$license = $req->get_parameter('omb_listenee_license');
if ($license && !common_valid_http_url($license)) {
$this->clientError(sprintf(_("Invalid license URL '%s'"), $license));
return false;
}
$profile_url = $req->get_parameter('omb_listenee_profile');
if ($profile_url && !common_valid_http_url($profile_url)) {
$this->clientError(sprintf(_("Invalid profile URL '%s'."), $profile_url));
return false;
}
# optional stuff
$fullname = $req->get_parameter('omb_listenee_fullname');
if ($fullname && mb_strlen($fullname) > 255) {
$this->clientError(_("Full name is too long (max 255 chars)."));
return false;
}
$homepage = $req->get_parameter('omb_listenee_homepage');
if ($homepage && (!common_valid_http_url($homepage) || mb_strlen($homepage) > 255)) {
$this->clientError(sprintf(_("Invalid homepage '%s'"), $homepage));
return false;
}
$bio = $req->get_parameter('omb_listenee_bio');
if ($bio && mb_strlen($bio) > 140) {
$this->clientError(_("Bio is too long (max 140 chars)."));
return false;
}
$location = $req->get_parameter('omb_listenee_location');
if ($location && mb_strlen($location) > 255) {
$this->clientError(_("Location is too long (max 255 chars)."));
return false;
}
$avatar = $req->get_parameter('omb_listenee_avatar');
if ($avatar) {
if (!common_valid_http_url($avatar) || strlen($avatar) > 255) {
$this->clientError(sprintf(_("Invalid avatar URL '%s'"), $avatar));
return false;
}
$size = @getimagesize($avatar);
if (!$size) {
$this->clientError(sprintf(_("Can't read avatar URL '%s'"), $avatar));
return false;
}
if ($size[0] != AVATAR_PROFILE_SIZE || $size[1] != AVATAR_PROFILE_SIZE) {
$this->clientError(sprintf(_("Wrong size image at '%s'"), $avatar));
return false;
}
if (!in_array($size[2], array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG))) {
$this->clientError(sprintf(_("Wrong image type for '%s'"), $avatar));
return false;
}
}
$orig_profile = clone $profile;
/* Use values even if they are an empty string. Parsing an empty string in
updateProfile is the specified way of clearing a parameter in OMB. */
if (!is_null($nickname)) {
$profile->nickname = $nickname;
}
if (!is_null($profile_url)) {
$profile->profileurl = $profile_url;
}
if (!is_null($fullname)) {
$profile->fullname = $fullname;
}
if (!is_null($homepage)) {
$profile->homepage = $homepage;
//.........这里部分代码省略.........