ここの情報は古いです。ご理解頂いた上でお取り扱いください。

source: OpenPNE3/trunk/lib/routing/opMailRoute.class.php @ 11786

Last change on this file since 11786 was 11786, checked in by ebihara, 11 years ago

#3970:added a system to do something on getting e-mail and added ability to add member photos from the mobile_frontend application.

Yeah, this change is very filthy. But I think that that is so important step for OpenPNE.

File size: 1.8 KB
Line 
1<?php
2
3/**
4 * This file is part of the OpenPNE package.
5 * (c) OpenPNE Project (http://www.openpne.jp/)
6 *
7 * For the full copyright and license information, please view the LICENSE
8 * file and the NOTICE file that were distributed with this source code.
9 */
10
11/**
12 * opMailRoute
13 *
14 * @package    OpenPNE
15 * @subpackage routing
16 * @author     Kousuke Ebihara <ebihara@tejimaya.com>
17 */
18class opMailRoute extends sfRoute
19{
20  protected $member = null;
21
22  public function getMember()
23  {
24    if (is_null($this->member))
25    {
26      $config = Doctrine::getTable('MemberConfig')->retrieveByNameAndValue('mobile_address', $this->context['from_address']);
27      if ($config)
28      {
29        $this->member = $config->getMember();
30      }
31    }
32
33    return $this->member;
34  }
35
36  protected function fixSuffix()
37  {
38    parent::fixSuffix();
39
40    if (sfConfig::get('op_is_mail_address_contain_hash', false))
41    {
42      $this->pattern = $this->pattern.'.:hash';
43    }
44  }
45
46  public function generate($params, $context = array(), $absolute = false)
47  {
48    if (!$this->compiled)
49    {
50      $this->compile();
51    }
52
53    $url = $this->pattern;
54    $defaults = $this->mergeArrays($this->getDefaultParameters(), $this->defaults);
55    $tparams = $this->mergeArrays($defaults, $params);
56
57    // all params must be given
58    if ($diff = array_diff_key($this->variables, $tparams))
59    {
60      throw new InvalidArgumentException(sprintf('The "%s" route has some missing mandatory parameters (%s).', $this->pattern, implode(', ', $diff)));
61    }
62
63    // replace variables
64    $variables = $this->variables;
65    uasort($variables, create_function('$a, $b', 'return strlen($a) < strlen($b);'));
66    foreach ($variables as $variable => $value)
67    {
68      $url = str_replace($value, urlencode($tparams[$variable]), $url);
69    }
70
71    return $url;
72  }
73}
Note: See TracBrowser for help on using the repository browser.