public function run() { if (cmsUser::isLogged()) { $this->redirectToHome(); } $users_model = cmsCore::getModel('users'); $form = $this->getForm('restore'); $data = array(); $is_submitted = $this->request->has('submit'); if ($is_submitted) { $data = $form->parse($this->request, $is_submitted); $errors = $form->validate($this, $data); if ($errors) { cmsUser::addSessionMessage(LANG_FORM_ERRORS, 'error'); } if (!$errors) { $user = $users_model->getUserByEmail($data['email']); if (!$user) { cmsUser::addSessionMessage(LANG_EMAIL_NOT_FOUND, 'error'); } else { $pass_token = string_random(32, $user['email']); $users_model->updateUserPassToken($user['id'], $pass_token); $messenger = cmsCore::getController('messages'); $to = array('email' => $user['email'], 'name' => $user['nickname']); $letter = array('name' => 'reg_restore'); $messenger->sendEmail($to, $letter, array('nickname' => $user['nickname'], 'page_url' => href_to_abs('auth', 'reset', $pass_token), 'valid_until' => html_date(date('d.m.Y H:i', time() + 24 * 3600), true))); cmsUser::addSessionMessage(LANG_TOKEN_SENDED, 'success'); } } } return cmsTemplate::getInstance()->render('restore', array('data' => $data, 'form' => $form, 'errors' => isset($errors) ? $errors : false)); }
private function sendInvites($profile, $emails_list) { $results = array('success' => array(), 'failed' => array()); $emails = string_explode_list($emails_list); $auth_controller = cmsCore::getController('auth'); $auth_model = cmsCore::getModel('auth'); $messenger = cmsCore::getController('messages'); foreach ($emails as $email) { if ($this->validate_email($email) !== true) { $results['failed'][$email] = ERR_VALIDATE_EMAIL; continue; } if ($this->model->getUserByEmail($email)) { $results['failed'][$email] = LANG_REG_EMAIL_EXISTS; continue; } if (!$auth_controller->isEmailAllowed($email)) { $results['failed'][$email] = LANG_AUTH_RESTRICTED_EMAILS; continue; } $invite = $auth_model->getNextInvite($this->cms_user->id); $to = array('email' => $email, 'name' => $email); $letter = array('name' => 'users_invite'); $messenger->sendEmail($to, $letter, array('nickname' => $this->cms_user->nickname, 'code' => $invite['code'], 'page_url' => href_to_abs('auth', 'register') . "?inv={$invite['code']}")); $results['success'][$email] = true; $auth_model->markInviteSended($invite['id'], $this->cms_user->id, $email); if (sizeof($results['success']) + sizeof($results['failed']) >= $profile['invites_count']) { break; } } return $results; }
private function notifyProfileOwner($profile_id, $entry) { if ($entry['user_id'] == $profile_id) { return; } $messenger = cmsCore::getController('messages'); $messenger->addRecipient($profile_id); $messenger->sendNoticeEmail('wall_reply', array('profile_url' => href_to_abs('users', $profile_id) . "?wid={$entry['id']}&reply=1", 'author_url' => href_to_abs('users', $entry['user_id']), 'author_nickname' => $entry['user_nickname'], 'content' => $entry['content_html'])); }
public function notifyAuthor($ctype_name, $item) { $users_model = cmsCore::getModel('users'); $author = $users_model->getUser($item['user_id']); $messenger = cmsCore::getController('messages'); $to = array('email' => $author['email'], 'name' => $author['nickname']); $letter = array('name' => 'moderation_approved'); $messenger->sendEmail($to, $letter, array('nickname' => $author['nickname'], 'page_title' => $item['title'], 'page_url' => href_to_abs($ctype_name, $item['slug'] . ".html"), 'date' => html_date_time())); }
public function run($data) { list($ctype, $profile) = $data; if (!empty($ctype['options']['is_rss'])) { $title = $profile['nickname'] . ' - ' . $ctype['title']; $feed_title = sprintf(LANG_RSS_FEED_TITLE_FORMAT, $title, cmsConfig::get('sitename')); $feed_url = href_to_abs($this->name, 'feed', $ctype['name']) . '?user='******'id']; $link_tag = '<link title="' . $feed_title . '" type="application/rss+xml" rel="alternate" href="' . $feed_url . '">'; cmsTemplate::getInstance()->addHead($link_tag); } return array($ctype, $profile); }
public function run($type) { $urls = array(); if ($type != 'profiles') { return $urls; } $groups = $this->model->limit(false)->getGroupsIds(); if ($groups) { foreach ($groups as $group) { $url = href_to_abs($this->name, $group['id']); $date_last_modified = false; $urls[$url] = $date_last_modified; } } return $urls; }
public function run($type) { $urls = array(); if ($type != 'profiles') { return $urls; } $users = $this->model->filterIsNull('is_locked')->limit(false)->getUsersIds(); if ($users) { foreach ($users as $user) { $url = href_to_abs($this->name, $user['id']); $date_last_modified = false; $urls[$url] = $date_last_modified; } } return $urls; }
public function sendNoticeRequest($friend) { $user = cmsUser::getInstance(); $messenger = cmsCore::getController('messages'); $messenger->addRecipient($friend['id']); // // Личное сообщение // $sender_link = '<a href="' . href_to($this->name, $user->id) . '">' . $user->nickname . '</a>'; $notice = array('content' => sprintf(LANG_USERS_FRIENDS_NOTICE, $sender_link), 'options' => array('is_closeable' => false), 'actions' => array('accept' => array('title' => LANG_ACCEPT, 'controller' => $this->name, 'action' => 'friend_add', 'params' => array($user->id)), 'decline' => array('title' => LANG_DECLINE, 'controller' => $this->name, 'action' => 'friend_delete', 'params' => array($user->id)))); // личное сообщение посылаем всегда, независимо от настроек уведомлений пользователя $messenger->ignoreNotifyOptions()->sendNoticePM($notice, 'users_friend_add'); // // E-mail // $messenger->sendNoticeEmail('users_friend_add', array('friend_nickname' => $user->nickname, 'friend_url' => href_to_abs('users', $user->id))); }
public function sendNoticeDeleted($friend, $is_declined = false) { $user = cmsUser::getInstance(); $messenger = cmsCore::getController('messages'); $messenger->addRecipient($friend['id']); $sender_link = '<a href="' . href_to($this->name, $user->id) . '">' . $user->nickname . '</a>'; $content = $is_declined ? sprintf(LANG_USERS_FRIENDS_DECLINED, $sender_link) : sprintf(LANG_USERS_FRIENDS_UNDONE, $sender_link); $notice = array('content' => $content); $messenger->sendNoticePM($notice, 'users_friend_delete'); // // E-mail // if (!$is_declined) { $messenger->sendNoticeEmail('users_friend_delete', array('friend_nickname' => $user->nickname, 'friend_url' => href_to_abs('users', $user->id))); } return true; }
public function run($data) { list($ctype, $category) = $data; if (!empty($ctype['options']['is_rss'])) { $title = $ctype['title']; if ($category['id'] > 1) { $title = $title . ' / ' . $category['title']; } $feed_title = sprintf(LANG_RSS_FEED_TITLE_FORMAT, $title, cmsConfig::get('sitename')); $feed_url = href_to_abs($this->name, 'feed', $ctype['name']); if ($category['id'] > 1) { $feed_url .= '?category=' . $category['id']; } $link_tag = '<link title="' . htmlspecialchars($feed_title) . '" type="application/rss+xml" rel="alternate" href="' . $feed_url . '">'; cmsTemplate::getInstance()->addHead($link_tag); } return array($ctype, $category); }
public function run($ctype_name) { $urls = array(); if (empty($ctype_name)) { return $urls; } $is_ctype_exists = $this->model->getContentTypeByName($ctype_name); if (!$is_ctype_exists) { return false; } $items = $this->model->filterNotEqual('is_private', 1)->filterNotEqual('is_approved', 0)->limit(false)->getContentItems($ctype_name); if ($items) { foreach ($items as $item) { $url = href_to_abs($ctype_name, $item['slug'] . '.html'); $date_last_modified = $item['date_last_modified']; $urls[$url] = $date_last_modified; } } return $urls; }
public function notifyParent($comment, $parent_comment) { if ($comment['user_id'] && $comment['user_id'] == $parent_comment['user_id']) { return; } $messenger = cmsCore::getController('messages'); $is_guest_parent = !$parent_comment['user_id'] && $parent_comment['author_email']; $is_guest_comment = !$comment['user_id']; $page_url = href_to_abs($comment['target_url']) . "#comment_{$comment['id']}"; $letter_data = array('page_url' => $page_url, 'page_title' => $comment['target_title'], 'author_url' => $is_guest_comment ? $page_url : href_to_abs('users', $comment['user_id']), 'author_nickname' => $is_guest_comment ? $comment['author_name'] : $comment['user_nickname'], 'comment' => $comment['content'], 'original' => $parent_comment['content']); if (!$is_guest_parent) { $messenger->addRecipient($parent_comment['user_id']); $messenger->sendNoticeEmail('comments_reply', $letter_data); } if ($is_guest_parent) { $letter_data['nickname'] = $parent_comment['author_name']; $to = array('name' => $parent_comment['author_name'], 'email' => $parent_comment['author_email']); $letter = array('name' => 'comments_reply'); $messenger->sendEmail($to, $letter, $letter_data); } }
public function sendInvite($invited_users_list, $group_id) { $user = cmsUser::getInstance(); $group = $this->model->getGroup($group_id); if (!$group) { cmsCore::error404(); } if (!is_array($invited_users_list)) { $invited_users_list = array($invited_users_list); } $messenger = cmsCore::getController('messages'); foreach ($invited_users_list as $invited_id) { $messenger->addRecipient($invited_id); // // Личное сообщение // $sender_link = '<a href="' . href_to('users', $user->id) . '">' . $user->nickname . '</a>'; $group_link = '<a href="' . href_to('groups', $group['id']) . '">' . $group['title'] . '</a>'; $notice = array('content' => sprintf(LANG_GROUPS_INVITE_NOTICE, $sender_link, $group_link), 'options' => array('is_closeable' => true), 'actions' => array('accept' => array('title' => LANG_ACCEPT, 'href' => href_to('groups', $group['id'], 'join')), 'decline' => array('title' => LANG_DECLINE, 'controller' => $this->name, 'action' => 'invite_delete', 'params' => array($group['id'], $invited_id)))); $messenger->sendNoticePM($notice, 'groups_invite'); // // E-mail // $messenger->sendNoticeEmail('groups_invite', array('user_nickname' => $user->nickname, 'user_url' => href_to_abs('users', $user->id), 'group_title' => $group['title'], 'group_url' => href_to_abs('groups', $group['id']))); $messenger->clearRecipients(); $this->model->addInvite(array('group_id' => $group['id'], 'user_id' => $user->id, 'invited_id' => $invited_id)); } cmsUser::addSessionMessage(LANG_GROUPS_INVITE_SENT, 'success'); $this->redirectBack(); }
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/"> <ShortName><?php html(sprintf(LANG_SEARCH_ON, $site_config->sitename)); ?> </ShortName> <Description><?php html(sprintf(LANG_SEARCH_ON, $site_config->sitename)); ?> </Description> <InputEncoding>utf-8</InputEncoding> <Image width="166" height="23" type="image/png"><?php echo $site_config->host . '/templates/' . $this->name . '/images/logo.png'; ?> </Image> <Url type="text/html" template="<?php echo href_to_abs('search') . '?q={searchTerms}'; ?> "/> </OpenSearchDescription>
public function requestModeration($ctype_name, $item, $is_new_item = true) { $moderator_id = $this->model->getNextModeratorId($ctype_name); $users_model = cmsCore::getModel('users'); $moderator = $users_model->getUser($moderator_id); $author = $users_model->getUser($item['user_id']); // добавляем задачу модератору $this->model->addModeratorTask($ctype_name, $moderator_id, $is_new_item, $item); // отправляем письмо модератору $messenger = cmsCore::getController('messages'); $to = array('email' => $moderator['email'], 'name' => $moderator['nickname']); $letter = array('name' => 'moderation'); $messenger->sendEmail($to, $letter, array('moderator' => $moderator['nickname'], 'author' => $author['nickname'], 'author_url' => href_to_abs('users', $author['id']), 'page_title' => $item['title'], 'page_url' => href_to_abs($ctype_name, $item['slug'] . ".html"), 'date' => html_date_time())); cmsUser::addSessionMessage(sprintf(LANG_MODERATION_IDLE, $moderator['nickname']), 'info'); }
<?php ob_start(); ?> <?php $sitemap_index_file = 'cache/static/sitemaps/sitemap.xml'; ?> <fieldset> <legend><?php echo LANG_INFORMATION; ?> </legend> <p> <?php printf(LANG_SITEMAP_INFO_CRON, href_to('admin', 'settings', 'scheduler')); ?> <br> <?php printf(LANG_SITEMAP_INFO_URL, href_to('sitemap.xml'), href_to_abs('sitemap.xml')); ?> </p> </fieldset> <?php $append_html = ob_get_clean(); ?> <?php $this->renderForm($form, $options, array('action' => '', 'method' => 'post', 'append_html' => $append_html), $errors);
public function run() { if (cmsUser::isLogged() && !cmsUser::isAdmin()) { $this->redirectToHome(); } $users_model = cmsCore::getModel('users'); $form = $this->getForm('registration'); // // Добавляем поле для кода приглашения, // если регистрация доступна только по приглашениям // if ($this->options['is_reg_invites']) { $fieldset_id = $form->addFieldsetToBeginning(LANG_REG_INVITED_ONLY); $form->addField($fieldset_id, new fieldString('inv', array('title' => LANG_REG_INVITE_CODE, 'rules' => array(array('required'), array('min_length', 10), array('max_length', 10))))); } // // Добавляем поле выбора группы, // при наличии публичных групп // $public_groups = $users_model->getPublicGroups(); if ($public_groups) { $pb_items = array(); foreach ($public_groups as $pb) { $pb_items[$pb['id']] = $pb['title']; } $form->addFieldToBeginning('basic', new fieldList('group_id', array('title' => LANG_USER_GROUP, 'items' => $pb_items))); } // // Добавляем в форму обязательные поля профилей // $content_model = cmsCore::getModel('content'); $content_model->setTablePrefix(''); $content_model->orderBy('ordering'); $fields = $content_model->getRequiredContentFields('users'); // Разбиваем поля по группам $fieldsets = cmsForm::mapFieldsToFieldsets($fields); // Добавляем поля в форму foreach ($fieldsets as $fieldset) { $fieldset_id = $form->addFieldset($fieldset['title']); foreach ($fieldset['fields'] as $field) { if ($field['is_system']) { continue; } $form->addField($fieldset_id, $field['handler']); } } $user = array(); if ($this->request->hasInQuery('inv')) { $user['inv'] = $this->request->get('inv'); } $is_submitted = $this->request->has('submit'); if ($is_submitted) { if (!$this->options['is_reg_enabled']) { cmsCore::error404(); } $errors = false; $is_captcha_valid = true; // // Проверяем капчу // if ($this->options['reg_captcha']) { $is_captcha_valid = cmsEventsManager::hook('captcha_validate', $this->request); if (!$is_captcha_valid) { $errors = true; cmsUser::addSessionMessage(LANG_CAPTCHA_ERROR, 'error'); } } // // Парсим и валидируем форму // if (!$errors) { $user = $form->parse($this->request, $is_submitted); $user['groups'] = array(); if (!empty($this->options['def_groups'])) { $user['groups'] = $this->options['def_groups']; } if (isset($user['group_id'])) { if (!in_array($user['group_id'], $user['groups'])) { $user['groups'][] = $user['group_id']; } } // // убираем поля которые не относятся к выбранной пользователем группе // foreach ($fieldsets as $fieldset) { foreach ($fieldset['fields'] as $field) { if (!$field['groups_edit']) { continue; } if (in_array(0, $field['groups_edit'])) { continue; } if (!in_array($user['group_id'], $field['groups_edit'])) { $form->disableField($field['name']); unset($user[$field['name']]); } } } $errors = $form->validate($this, $user); } if (!$errors) { // // проверяем код приглашения // if ($this->options['is_reg_invites']) { $invite = $this->model->getInviteByCode($user['inv']); if (!$invite) { $errors['inv'] = LANG_REG_WRONG_INVITE_CODE; } else { if ($this->options['is_invites_strict'] && $invite['email'] != $user['email']) { $errors['inv'] = LANG_REG_WRONG_INVITE_CODE_EMAIL; } else { $user['inviter_id'] = $invite['user_id']; } } } // // проверяем допустимость e-mail, имени и IP // if (!$this->isEmailAllowed($user['email'])) { $errors['email'] = sprintf(LANG_AUTH_RESTRICTED_EMAIL, $user['email']); } if (!$this->isNameAllowed($user['nickname'])) { $errors['nickname'] = sprintf(LANG_AUTH_RESTRICTED_NAME, $user['nickname']); } if (!$this->isIPAllowed(cmsUser::get('ip'))) { cmsUser::addSessionMessage(sprintf(LANG_AUTH_RESTRICTED_IP, cmsUser::get('ip')), 'error'); $errors = true; } } if (!$errors) { unset($user['inv']); // // Блокируем пользователя, если включена верификация e-mail // if ($this->options['verify_email']) { $user = array_merge($user, array('is_locked' => true, 'lock_reason' => LANG_REG_CFG_VERIFY_LOCK_REASON, 'pass_token' => string_random(32, $user['email']), 'date_token' => '')); } $result = $users_model->addUser($user); if ($result['success']) { $user['id'] = $result['id']; cmsUser::addSessionMessage(LANG_REG_SUCCESS, 'success'); // отправляем письмо верификации e-mail if ($this->options['verify_email']) { $messenger = cmsCore::getController('messages'); $to = array('email' => $user['email'], 'name' => $user['nickname']); $letter = array('name' => 'reg_verify'); $messenger->sendEmail($to, $letter, array('nickname' => $user['nickname'], 'page_url' => href_to_abs('auth', 'verify', $user['pass_token']), 'valid_until' => html_date(date('d.m.Y H:i', time() + $this->options['verify_exp'] * 3600), true))); cmsUser::addSessionMessage(sprintf(LANG_REG_SUCCESS_NEED_VERIFY, $user['email']), 'info'); } else { cmsEventsManager::hook('user_registered', $user); } $back_url = cmsUser::sessionGet('auth_back_url') ? cmsUser::sessionGet('auth_back_url', true) : false; if ($back_url) { $this->redirect($back_url); } else { $this->redirectToHome(); } } else { $errors = $result['errors']; } } if ($errors && $is_captcha_valid) { cmsUser::addSessionMessage(LANG_FORM_ERRORS, 'error'); } } // Капча if ($this->options['reg_captcha']) { $captcha_html = cmsEventsManager::hook('captcha_html'); } return cmsTemplate::getInstance()->render('registration', array('user' => $user, 'form' => $form, 'captcha_html' => isset($captcha_html) ? $captcha_html : false, 'errors' => isset($errors) ? $errors : false)); }
public function notifyModerators($comment) { // проверяем, нет ли уже комментариев на модерации $this->model->disableApprovedFilter()->filterNotEqual('is_approved', 1); $count = $this->model->getCommentsCount(); $this->model->resetFilters(); // если больше одного, значит уже уведомления рассылали if ($count > 1) { return false; } $messenger = cmsCore::getController('messages'); // рассылаем модераторам уведомления $moderators = $this->model->getCommentsModerators(); foreach ($moderators as $moderator) { $messenger->addRecipient($moderator['id']); $messenger->sendNoticePM(array('content' => LANG_COMMENTS_MODERATE_NOTIFY, 'actions' => array('view' => array('title' => LANG_SHOW, 'href' => href_to('comments', 'index', 'moderation'))))); if (!$moderator['is_online']) { $page_url = href_to_abs($comment['target_url']) . "#comment_{$comment['id']}"; $messenger->sendEmail(array('email' => $moderator['email'], 'name' => $moderator['nickname']), 'comments_moderate', array('author_nickname' => !$comment['user_id'] ? $comment['author_name'] : $comment['user_nickname'], 'author_url' => !$comment['user_id'] ? $page_url : href_to_abs('users', $comment['user_id']), 'page_url' => $page_url, 'comment' => strip_tags($comment['content_html']), 'nickname' => $moderator['nickname'], 'list_url' => href_to_abs('comments', 'index', 'moderate'))); } } }
if (!empty($image[$feed['mapping']['image_size']])) { ?> <enclosure url="<?php echo cmsConfig::get('upload_host_abs') . '/' . $image[$feed['mapping']['image_size']]; ?> " /> <?php } ?> <?php } ?> <link><?php echo href_to_abs($feed['ctype_name'], $item['slug'] . '.html'); ?> </link> <guid><?php echo href_to_abs($feed['ctype_name'], $item['slug'] . '.html'); ?> </guid> </item> <?php } ?> <?php } ?> </channel> </rss>