예제 #1
0
파일: Send.php 프로젝트: Dulciane/jaws
 /**
  * Send email to recipient
  *
  * @access  public
  * @param   string   $to   Recipient email address
  * @param   int      $cid   Contact ID
  * @return  mixed    True on Success or Jaws_Error on Failure
  */
 function SendEmailToRecipient($to, $cid)
 {
     $model = $this->gadget->model->load('Contacts');
     $contact = $model->GetContact($cid);
     if (Jaws_Error::IsError($contact)) {
         return $contact;
     }
     if (!isset($contact['id'])) {
         return new Jaws_Error(_t('CONTACT_ERROR_CONTACT_DOES_NOT_EXISTS'));
     }
     $from_name = $contact['name'];
     $from_email = $contact['email'];
     $site_url = $GLOBALS['app']->getSiteURL('/');
     $site_name = $this->gadget->registry->fetch('site_name', 'Settings');
     $format = $this->gadget->registry->fetch('email_format');
     if ($format == 'html') {
         $message = Jaws_String::AutoParagraph($contact['msg_txt']);
     } else {
         $message = $contact['msg_txt'];
     }
     $tpl = $this->gadget->template->load('SendToRecipient.html');
     $tpl->SetBlock($format);
     $tpl->SetVariable('lbl_name', _t('GLOBAL_NAME'));
     $tpl->SetVariable('lbl_email', _t('GLOBAL_EMAIL'));
     $tpl->SetVariable('lbl_company', _t('CONTACT_COMPANY'));
     $tpl->SetVariable('lbl_url', _t('GLOBAL_URL'));
     $tpl->SetVariable('lbl_tel', _t('CONTACT_TEL'));
     $tpl->SetVariable('lbl_fax', _t('CONTACT_FAX'));
     $tpl->SetVariable('lbl_mobile', _t('CONTACT_MOBILE'));
     $tpl->SetVariable('lbl_address', _t('CONTACT_ADDRESS'));
     $tpl->SetVariable('lbl_recipient', _t('CONTACT_RECIPIENT'));
     $tpl->SetVariable('lbl_subject', _t('CONTACT_SUBJECT'));
     $tpl->SetVariable('lbl_message', _t('CONTACT_MESSAGE'));
     $tpl->SetVariable('name', $contact['name']);
     $tpl->SetVariable('email', $contact['email']);
     $tpl->SetVariable('company', $contact['company']);
     $tpl->SetVariable('url', $contact['url']);
     $tpl->SetVariable('tel', $contact['tel']);
     $tpl->SetVariable('fax', $contact['fax']);
     $tpl->SetVariable('mobile', $contact['mobile']);
     $tpl->SetVariable('address', $contact['address']);
     $tpl->SetVariable('recipient', $to);
     $tpl->SetVariable('subject', $contact['subject']);
     $tpl->SetVariable('message', $message);
     $tpl->SetVariable('site-name', $site_name);
     $tpl->SetVariable('site-url', $site_url);
     $tpl->ParseBlock($format);
     $template = $tpl->Get();
     $mail = Jaws_Mail::getInstance();
     $mail->SetFrom($from_email, $from_name);
     $mail->AddRecipient($to);
     $mail->SetSubject(Jaws_XSS::defilter($contact['subject']));
     $mail->SetBody($template, $format);
     $result = $mail->send();
     if (Jaws_Error::IsError($result)) {
         return $result;
     }
     return true;
 }
예제 #2
0
파일: Profile.php 프로젝트: uda/jaws
 /**
  * Builds user information page include (personal, contact, ... information)
  *
  * @access  public
  * @return  string  XHTML template content
  */
 function Profile()
 {
     $user = jaws()->request->fetch('user', 'get');
     if (empty($user)) {
         return Jaws_HTTPError::Get(404);
     }
     $usrModel = new Jaws_User();
     $user = $usrModel->GetUser($user, true, true, true);
     if (Jaws_Error::IsError($user) || empty($user)) {
         return Jaws_HTTPError::Get(404);
     }
     // Avatar
     $user['avatar'] = $usrModel->GetAvatar($user['avatar'], $user['email'], 128, $user['last_update']);
     // Gender
     $user['gender'] = _t('USERS_USERS_GENDER_' . $user['gender']);
     // Date of birth
     $objDate = Jaws_Date::getInstance();
     $user['dob'] = $objDate->Format($user['dob'], 'd MN Y');
     if (!empty($user['registered_date'])) {
         $user['registered_date'] = $objDate->Format($user['registered_date'], 'd MN Y');
     } else {
         $user['registered_date'] = '';
     }
     // Load the template
     $tpl = $this->gadget->template->load('Profile.html');
     $tpl->SetBlock('profile');
     $tpl->SetVariable('title', _t('USERS_PROFILE_INFO'));
     $tpl->SetVariable('menubar', $this->MenuBar('Profile'));
     $tpl->SetVariable('submenubar', $this->SubMenuBar('Profile', array('Profile', 'Account', 'Personal', 'Preferences', 'Contacts')));
     $tpl->SetVariable('avatar', $user['avatar']);
     // username
     $tpl->SetVariable('lbl_username', _t('USERS_USERS_USERNAME'));
     $tpl->SetVariable('username', $user['username']);
     // nickname
     $tpl->SetVariable('lbl_nickname', _t('USERS_USERS_NICKNAME'));
     $tpl->SetVariable('nickname', $user['nickname']);
     // registered_date
     $tpl->SetVariable('lbl_registered_date', _t('USERS_USERS_REGISTRATION_DATE'));
     $tpl->SetVariable('registered_date', $user['registered_date']);
     // auto paragraph content
     $user['about'] = Jaws_String::AutoParagraph($user['about']);
     $user = $user + array('lbl_private' => _t('USERS_USERS_PRIVATE'), 'lbl_fname' => _t('USERS_USERS_FIRSTNAME'), 'lbl_lname' => _t('USERS_USERS_LASTNAME'), 'lbl_gender' => _t('USERS_USERS_GENDER'), 'lbl_ssn' => _t('USERS_USERS_SSN'), 'lbl_dob' => _t('USERS_USERS_BIRTHDAY'), 'lbl_public' => _t('USERS_USERS_PUBLIC'), 'lbl_url' => _t('GLOBAL_URL'), 'lbl_about' => _t('USERS_USERS_ABOUT'), 'lbl_experiences' => _t('USERS_USERS_EXPERIENCES'), 'lbl_occupations' => _t('USERS_USERS_OCCUPATIONS'), 'lbl_interests' => _t('USERS_USERS_INTERESTS'));
     if (!$GLOBALS['app']->Session->IsSuperAdmin() && $GLOBALS['app']->Session->GetAttribute('user') != $user['id']) {
         $user['ssn'] = _t('GLOBAL_ERROR_ACCESS_DENIED');
     }
     // set about item data
     $tpl->SetVariablesArray($user);
     if ($user['public'] || $GLOBALS['app']->Session->Logged()) {
         $tpl->SetBlock('profile/public');
         // set profile item data
         $tpl->SetVariablesArray($user);
         if (!empty($user['url'])) {
             $tpl->SetBlock('profile/public/website');
             $tpl->SetVariable('url', $user['url']);
             $tpl->ParseBlock('profile/public/website');
         }
         $tpl->ParseBlock('profile/public');
     }
     $tpl->SetBlock('profile/activity');
     $tpl->SetVariable('lbl_activities', _t('USERS_USER_ACTIVITIES'));
     $this->Activity($tpl, $user['id'], $user['username']);
     $tpl->ParseBlock('profile/activity');
     $tpl->ParseBlock('profile');
     return $tpl->Get();
 }
예제 #3
0
파일: Comments.php 프로젝트: juniortux/jaws
 /**
  * Get the comments messages list
  *
  * @access  public
  * @return  string  XHTML template content
  */
 function GetMessages()
 {
     $rqst = jaws()->request->fetch(array('order', 'perpage', 'page'), 'get');
     $page = empty($rqst['page']) ? 1 : (int) $rqst['page'];
     if (!empty($rqst['perpage'])) {
         $perPage = (int) $rqst['perpage'];
         $orderBy = (int) $rqst['order'];
     } else {
         $perPage = $this->gadget->registry->fetch('comments_per_page');
         $orderBy = 0;
     }
     $model = $this->gadget->model->load('Comments');
     $comments = $model->GetComments($this->gadget->name, '', '', '', array(Comments_Info::COMMENTS_STATUS_APPROVED), $perPage, ($page - 1) * $perPage, $orderBy);
     $comments_count = $model->GetCommentsCount($this->gadget->name, '', '', '', array(Comments_Info::COMMENTS_STATUS_APPROVED));
     $tpl = $this->gadget->template->load('Comments.html');
     $tpl->SetBlock('comments');
     $tpl->SetVariable('gadget', strtolower($this->gadget->name));
     $objDate = Jaws_Date::getInstance();
     $usrModel = new Jaws_User();
     if (!Jaws_Error::IsError($comments) && $comments != null) {
         foreach ($comments as $entry) {
             $tpl->SetBlock('comments/entry');
             $tpl->SetVariable('postedby_lbl', _t('COMMENTS_POSTEDBY'));
             if ($entry['user_registered_date']) {
                 $tpl->SetBlock('comments/entry/registered_date');
                 $tpl->SetVariable('registered_date_lbl', _t('COMMENTS_USERS_REGISTERED_DATE'));
                 $tpl->SetVariable('registered_date', $objDate->Format($entry['user_registered_date'], 'd MN Y'));
                 $tpl->ParseBlock('comments/entry/registered_date');
             }
             if (!empty($entry['username'])) {
                 // user's profile
                 $tpl->SetVariable('user_url', $GLOBALS['app']->Map->GetURLFor('Users', 'Profile', array('user' => $entry['username'])));
             } else {
                 $tpl->SetVariable('user_url', Jaws_XSS::filter($entry['url']));
             }
             $nickname = empty($entry['nickname']) ? $entry['name'] : $entry['nickname'];
             $email = empty($entry['user_email']) ? $entry['email'] : $entry['user_email'];
             $tpl->SetVariable('nickname', Jaws_XSS::filter($nickname));
             $tpl->SetVariable('email', Jaws_XSS::filter($email));
             $tpl->SetVariable('username', Jaws_XSS::filter($entry['username']));
             // user's avatar
             $tpl->SetVariable('avatar', $usrModel->GetAvatar($entry['avatar'], $entry['email'], 80));
             $tpl->SetVariable('insert_time', $objDate->Format($entry['createtime']));
             $tpl->SetVariable('insert_time_iso', $objDate->ToISO($entry['createtime']));
             $tpl->SetVariable('message', Jaws_String::AutoParagraph($entry['msg_txt']));
             $tpl->ParseBlock('comments/entry');
         }
     }
     // page navigation
     $this->GetPagesNavigation($tpl, 'comments', $page, $perPage, $comments_count, _t('COMMENTS_COMMENTS_COUNT', $comments_count), 'Comments', array('perpage' => $perPage, 'order' => $orderBy));
     $tpl->ParseBlock('comments');
     return $tpl->Get();
 }
예제 #4
0
파일: Feeds.php 프로젝트: uda/jaws
 /**
  * Create ATOM struct of recent comments
  *
  * @access  private
  * @param   string  $gadget     Gadget name
  * @param   string  $action     Action name
  * @param   int     $reference  Reference Id
  * @param   string  $feed_type feed type
  * @return  object  Can return the Atom Object
  */
 function GetRecentCommentsAtomStruct($gadget, $action = null, $reference = null, $feed_type = 'atom')
 {
     $max_title_size = 80;
     $cModel = $this->gadget->model->load('Comments');
     $comments = $cModel->GetComments($gadget, $action, $reference, '', array(Comments_Info::COMMENTS_STATUS_APPROVED));
     if (Jaws_Error::IsError($comments)) {
         return new Jaws_Error(_t('COMMENTS_ERROR_GETTING_COMMENTS_ATOMSTRUCT'));
     }
     $commentAtom = new Jaws_AtomFeed();
     $siteURL = $GLOBALS['app']->GetSiteURL('/');
     $params = array('gadgetname' => $gadget);
     if (!empty($action)) {
         $params['actionname'] = $action;
     }
     if (!empty($reference)) {
         $params['reference'] = $reference;
     }
     $url = $this->gadget->urlMap($feed_type == 'atom' ? 'RecentCommentsAtom' : 'RecentCommentsRSS', $params, true);
     $commentAtom->SetTitle($this->gadget->registry->fetch('site_name', 'Settings'));
     $commentAtom->SetLink($url);
     $commentAtom->SetId($siteURL);
     $commentAtom->SetAuthor($this->gadget->registry->fetch('site_author', 'Settings'), $GLOBALS['app']->GetSiteURL('/'), $this->gadget->registry->fetch('gate_email', 'Settings'));
     $commentAtom->SetGenerator('JAWS ' . $GLOBALS['app']->Registry->fetch('version'));
     $commentAtom->SetCopyright($this->gadget->registry->fetch('site_copyright', 'Settings'));
     $commentAtom->SetTagLine(_t('COMMENTS_RECENT_COMMENTS', _t(strtoupper($gadget) . '_TITLE')));
     $objDate = Jaws_Date::getInstance();
     $site = preg_replace('/(.*)\\/.*/i', '\\1', $commentAtom->Link->HRef);
     foreach ($comments as $c) {
         $entry_id = $c['reference'];
         $entry = new AtomEntry();
         $entry->SetTitle(Jaws_UTF8::strlen($c['msg_txt']) >= $max_title_size ? Jaws_UTF8::substr($c['msg_txt'], 0, $max_title_size) . '...' : $c['msg_txt']);
         $entry->SetId("urn:gadget:{$gadget}:action:{$action}:reference:{$reference}:comment:{$c['id']}");
         switch ($gadget) {
             case 'Blog':
                 // So we can use the UrlMapping feature.
                 $url = $GLOBALS['app']->Map->GetURLFor('Blog', 'SingleView', array('id' => $entry_id), true);
                 $url = $url . htmlentities('#comment' . $c['id']);
                 $entry->SetLink($url);
                 break;
             case 'Phoo':
                 $url = $GLOBALS['app']->Map->GetURLFor('Phoo', 'ViewImage', array('id' => $entry_id), true);
                 $url = $url . htmlentities('#comment' . $c['id']);
                 $entry->SetLink($url);
                 break;
             case 'Shoutbox':
                 $url = $GLOBALS['app']->Map->GetURLFor('Shoutbox', 'Comments', array(), true);
                 $url = $url . htmlentities('#comment' . $c['id']);
                 $entry->SetLink($url);
                 break;
         }
         $content = Jaws_String::AutoParagraph($c['msg_txt']);
         $entry->SetSummary($content, 'html');
         $entry->SetContent($content, 'html');
         $entry->SetAuthor($c['name'], $commentAtom->Link->HRef, $c['email']);
         $entry->SetPublished($objDate->ToISO($c['insert_time']));
         $entry->SetUpdated($objDate->ToISO($c['insert_time']));
         $commentAtom->AddEntry($entry);
         if (!isset($last_modified)) {
             $last_modified = $c['insert_time'];
         }
     }
     if (isset($last_modified)) {
         $commentAtom->SetUpdated($objDate->ToISO($last_modified));
     } else {
         $commentAtom->SetUpdated($objDate->ToISO(date('Y-m-d H:i:s')));
     }
     return $commentAtom;
 }
예제 #5
0
파일: Gadget.php 프로젝트: juniortux/jaws
 /**
  * Parses the input text
  *
  * @access  public
  * @param   string  $text           The Text to parse
  * @param   string  $gadget         The Gadget name
  * @param   string  $plugins_set    Plugins set name(admin or index)
  * @return  string  Returns the parsed text
  */
 function ParseText($text, $gadget = '', $plugins_set = 'admin')
 {
     $res = $text;
     $gadget = empty($gadget) ? $this->name : $gadget;
     $plugins = $GLOBALS['app']->Registry->fetch('plugins_installed_items');
     if (!Jaws_Error::isError($plugins) && !empty($plugins)) {
         $plugins = array_filter(explode(',', $plugins));
         foreach ($plugins as $plugin) {
             $objPlugin = $GLOBALS['app']->LoadPlugin($plugin);
             if (!Jaws_Error::IsError($objPlugin)) {
                 $use_in = '*';
                 if ($plugins_set == 'admin') {
                     $use_in = $GLOBALS['app']->Registry->fetch('backend_gadgets', $plugin);
                 } else {
                     $use_in = $GLOBALS['app']->Registry->fetch('frontend_gadgets', $plugin);
                 }
                 if (!Jaws_Error::isError($use_in) && ($use_in == '*' || in_array($gadget, explode(',', $use_in)))) {
                     $res = $objPlugin->ParseText($res);
                 }
             }
         }
     }
     //So we don't call require_once each time we invoke it
     if (!Jaws::classExists('Jaws_String')) {
         require JAWS_PATH . 'include/Jaws/String.php';
     }
     $res = Jaws_String::AutoParagraph($res);
     return $res;
 }