public function execute(&$value, &$error)
 {
     $user_id = sfContext::getInstance()->getUser()->getId();
     $user_private_data = UserPrivateData::find($user_id);
     if (!myUser::check_password($value, $user_private_data->password)) {
         $error = $this->getParameterHolder()->get('bad_password_error');
         return false;
     }
     return true;
 }
Ejemplo n.º 2
0
 private static function signal()
 {
     $i18n = sfContext::getInstance()->getI18N();
     // send an email for potential vandalism
     $email_recipient = UserPrivateData::find(108544)->getEmail();
     // for now, topo-fr 108544
     $email_subject = $i18n->__('Potential vandalism');
     $server = $_SERVER['SERVER_NAME'];
     $module = self::$doc->getModule();
     $link = "http://{$server}/{$module}/" . self::$doc->getId();
     $htmlBody = $i18n->__('The document "%1%" has been potentially vandalised', array('%1%' => '<a href="' . $link . '">' . self::$doc->getCurrentI18nObject()->getName() . '</a>'));
     $mail = new sfMail();
     $mail->setCharset('utf-8');
     // definition of the required parameters
     $mail->setSender(sfConfig::get('app_outgoing_emails_sender'));
     $mail->setFrom(sfConfig::get('app_outgoing_emails_from'));
     $mail->addReplyTo(sfConfig::get('app_outgoing_emails_reply_to'));
     $mail->addAddress($email_recipient);
     $mail->setSubject($email_subject);
     $mail->setContentType('text/html');
     $mail->setBody($htmlBody);
     $mail->setAltBody(strip_tags($htmlBody));
     $mail->send();
 }
Ejemplo n.º 3
0
 public function executeTooltipTest()
 {
     $bbox = $this->getRequestParameter('bbox');
     $layers = $this->getRequestParameter('layers');
     // TODO check params
     $this->nb_items = 0;
     foreach (explode(',', $layers) as $layer) {
         list($module, $model, $type_where) = self::_getTooltipParamFromLayer($layer);
         $where = gisQuery::getQueryByBbox($bbox, 'geom', $module);
         $q = Doctrine_Query::create()->from("{$model} m")->where('m.redirects_to IS NULL')->addWhere($where['where_string']);
         if ($type_where) {
             $q->addWhere($type_where);
         }
         //$this->nb_items += $q->count(); TODO is it quickier to use directly count?
         $results = $q->execute();
         $this->nb_items += count($results);
         // save information that can be useful in next steps
         if ($results->getFirst()) {
             $sav_model = $model;
             $sav_id = $results->getFirst()->getId();
         }
     }
     // if only one result, directly display its name
     if ($this->nb_items == 1) {
         // specific behaviour for users: we don't want to display user name if profile
         // is private and user is not connected
         if ($sav_model == 'User' && !$this->getUser()->isConnected() && !UserPrivateData::hasPublicProfile($sav_id)) {
             $this->name = $this->__('not available');
         } else {
             $langs = sfContext::getInstance()->getUser()->getPreferedLanguageList();
             $i18n = Doctrine_Query::create()->select('m.culture, m.name')->from("{$sav_model}I18n m")->where('m.id = ?', array($sav_id))->execute();
             $old_lang = 200;
             foreach ($i18n as $name) {
                 $lang_pos = array_search($name->get('culture'), $langs);
                 if ($lang_pos === false) {
                     $lang_pos = 10;
                 }
                 // test if language is prefered over the older
                 if ($lang_pos < $old_lang) {
                     $old_lang = $lang_pos;
                     $uname = $name->get('name');
                 }
             }
             $this->name = $uname;
         }
     }
     $this->setJsonResponse();
 }
Ejemplo n.º 4
0
 // parse_message always use html_special_chars, and so does retrieval of the text
 echo $text;
 ?>
                 </p>
             </div>
         </div>
         <div class="clearer"></div>
         <div class="postfootright">
             <ul><?php 
 if ($sf_user->getId() > 1) {
     echo '<li class="postreport">' . f_link_to(__('Report'), 'misc.php?report=' . $comment->id) . ' | ';
 } else {
     echo '<li class="postreport">' . f_link_to(__('Report'), 'misc.php?email=' . sfConfig::get('app_moderator_forum_user_id') . '&doc=' . urlencode('/forums/viewtopic.php?pid=' . $comment->id . '#p' . $comment->id)) . ' | ';
 }
 // Following line is only ok because comments page is not cached
 $is_forum_moderator = UserPrivateData::isForumModerator($sf_user->getId());
 if ($is_forum_moderator) {
     echo '</li><li class="movepost">' . f_link_to(__('Move'), 'movepost.php?id=' . $comment->id) . ' | ';
 }
 if ($comment['poster_id'] == $sf_user->getId() || $is_forum_moderator) {
     echo '</li><li class="postedit">' . f_link_to(__('Edit'), 'edit.php?id=' . $comment->id) . ' | ';
 }
 echo '</li>';
 // check if anonymous comments allowed
 if ($sf_user->getId() > 1 || in_array($lang, sfConfig::get('app_anonymous_comments_allowed_list'))) {
     echo '<li class="postquote">' . f_link_to(__('Quoted reply'), 'post.php?tid=' . $topic_id . '&amp;' . 'qid=' . $comment->id, array('rel' => 'nofollow')) . '</li>';
 }
 ?>
             </ul>
         </div>
     </div>
Ejemplo n.º 5
0
 public function signUp($login_name, $password, $email)
 {
     // to improve DB access it's better to pass id for object save
     // save user
     $user = new User();
     $user->setCulture($this->getCulture());
     $user->setName($login_name);
     // absolutely needed for i18n record creation here !
     // Get data from YML config file.
     $master_user_id = sfConfig::get('app_user_creation_master_id');
     $is_minor = sfConfig::get('app_user_creation_is_minor');
     $comment = sfConfig::get('app_user_creation_comment');
     $user->doSaveWithMetadata($master_user_id, $is_minor, $comment);
     // save private data
     $private_data = new UserPrivateData();
     $private_data->setLoginName($login_name);
     $private_data->setUsername($login_name);
     // username is used as nickname in forum, need to be set
     $private_data->setTopoName($user->getName());
     $private_data->setPassword($password);
     $private_data->setEmail($email);
     $private_data->setPreferedLanguageList($this->getCulturesForDocuments());
     $private_data->setId($user->getId());
     $private_data->setGroupId(4);
     $private_data->setRegistered(time());
     $private_data->save();
     // add this user to pending users and logged
     $user->addToGroups(array('pending', 'logged'));
     return true;
 }
Ejemplo n.º 6
0
 public function executePopup()
 {
     $id = $this->getRequestParameter('id');
     // if user is not connected, we don't want to display user's popup
     if (!$this->getUser()->isConnected() && !UserPrivateData::hasPublicProfile($id)) {
         $this->raw = $this->getRequestParameter('raw', false);
         if ($this->raw) {
             $this->setLayout(false);
         }
         // deactivate automatic inclusion of js and css files by symfony
         $response = $this->getResponse();
         $response->setParameter('javascripts_included', true, 'symfony/view/asset');
         $response->setParameter('stylesheets_included', true, 'symfony/view/asset');
         $this->setCacheControl();
         // we call users/popupError template
         return sfView::ERROR;
     } else {
         parent::executePopup();
     }
 }
 /**
  * restore cookie values from profile. Managed cookies not in the profile will be deleted
  */
 public static function restorePrefCookies($user_id)
 {
     if (!($user_private_data = UserPrivateData::find($user_id))) {
         return;
         // silently stop
     }
     $response = sfContext::getInstance()->getResponse();
     $managed_cookies = sfConfig::get('app_profile_cookies_list');
     $fold_prefs = sfConfig::get('app_personalization_cookie_fold_positions');
     $cookie_prefs = $user_private_data->getPref_cookies();
     if (empty($cookie_prefs)) {
         // no saved value in profile, copy the current cookie values into profile
         // 'regular' cookies
         $cookie_values = array();
         foreach ($managed_cookies as $cookie) {
             if (sfContext::getInstance()->getRequest()->getCookie($cookie)) {
                 $cookie_values[$cookie] = urlencode(sfContext::getInstance()->getRequest()->getCookie($cookie));
             }
         }
         // fold prefs
         if (sfContext::getInstance()->getRequest()->getCookie('fold')) {
             $fold_cookie_value = sfContext::getInstance()->getRequest()->getCookie('fold');
             foreach ($fold_prefs as $pos => $pref) {
                 if ($fold_cookie_value[$pos] == 't') {
                     $cookie_values[$pref + '_home_status'] = 'true';
                 } else {
                     if ($fold_cookie_value[$pos] == 'f') {
                         $cookie_values[$pref + '_home_status'] = 'false';
                     }
                 }
             }
         }
         if (!empty($cookie_values)) {
             $conn = sfDoctrine::Connection();
             try {
                 $user_private_data->setPref_cookies($cookie_values);
                 $user_private_data->save();
                 $conn->commit();
             } catch (Exception $e) {
                 $conn->rollback();
             }
         }
     } else {
         // set fold cookie
         $fold_cookie_value = $default = str_repeat('x', sfConfig::get('app_personalization_cookie_fold_size'));
         foreach ($fold_prefs as $pos => $pref) {
             if (isset($cookie_prefs[$pref . '_home_status'])) {
                 $fold_cookie_value[$pos] = $cookie_prefs[$pref . '_home_status'] == 'true' ? 't' : 'f';
             }
         }
         if ($fold_cookie_value != $default) {
             $response->setCookie('fold', $fold_cookie_value, time() + sfConfig::get('app_personalization_filter_timeout'));
         } else {
             $response->setCookie('fold', '');
         }
         // erase all managed cookies or replace values with the one in profile
         foreach ($managed_cookies as $cookie_name) {
             if (array_key_exists($cookie_name, $cookie_prefs)) {
                 $response->setCookie($cookie_name, $cookie_prefs[$cookie_name], time() + sfConfig::get('app_personalization_filter_timeout'));
             } else {
                 $response->setCookie($cookie_name, '');
             }
         }
     }
 }