Ejemplo n.º 1
0
 /**
  * Download post attachment
  *
  * @access  public
  * @return  string   Requested file content or HTML error page
  */
 function Attachment()
 {
     $rqst = jaws()->request->fetch(array('fid', 'tid', 'pid', 'attach'), 'get');
     $pModel = $this->gadget->model->load('Posts');
     $post = $pModel->GetPost($rqst['pid'], $rqst['tid'], $rqst['fid']);
     if (Jaws_Error::IsError($post)) {
         $this->SetActionMode('Attachment', 'normal', 'standalone');
         return Jaws_HTTPError::Get(500);
     }
     $aModel = $this->gadget->model->load('Attachments');
     $attachment = $aModel->GetAttachmentInfo($rqst['attach']);
     if (Jaws_Error::IsError($attachment)) {
         $this->SetActionMode('Attachment', 'normal', 'standalone');
         return Jaws_HTTPError::Get(500);
     }
     if (!empty($attachment)) {
         $filepath = JAWS_DATA . 'forums/' . $attachment['filename'];
         if (file_exists($filepath)) {
             // increase download hits
             $result = $aModel->HitAttachmentDownload($rqst['attach']);
             if (Jaws_Error::IsError($result)) {
                 // do nothing
             }
             if (Jaws_Utils::Download($filepath, $attachment['title'])) {
                 return;
             }
             $this->SetActionMode('Attachment', 'normal', 'standalone');
             return Jaws_HTTPError::Get(500);
         }
     }
     $this->SetActionMode('Attachment', 'normal', 'standalone');
     return Jaws_HTTPError::Get(404);
 }
Ejemplo n.º 2
0
 /**
  * Download message attachment
  *
  * @access  public
  * @return  string   Requested file content or HTML error page
  */
 function Attachment()
 {
     if (!$GLOBALS['app']->Session->Logged()) {
         return Jaws_HTTPError::Get(401);
     }
     $rqst = jaws()->request->fetch(array('uid', 'mid', 'aid'), 'get');
     $user = $GLOBALS['app']->Session->GetAttribute('user');
     $mModel = $this->gadget->model->load('Message');
     $aModel = $this->gadget->model->load('Attachment');
     $message = $mModel->GetMessage($rqst['mid'], false, false);
     if (Jaws_Error::IsError($message)) {
         return Jaws_HTTPError::Get(500);
     }
     // Check permissions
     if (!($message['from'] == $user && $message['to'] == 0) && $message['to'] != $user || $user != $rqst['uid']) {
         return Jaws_HTTPError::Get(403);
     }
     $attachment = $aModel->GetAttachment($rqst['aid'], $rqst['mid']);
     if (!empty($attachment)) {
         $filepath = JAWS_DATA . 'pm' . DIRECTORY_SEPARATOR . 'attachments' . DIRECTORY_SEPARATOR . $attachment['filename'];
         if (file_exists($filepath)) {
             if (Jaws_Utils::Download($filepath, $attachment['title'], $attachment['filetype'])) {
                 return;
             }
             return Jaws_HTTPError::Get(500);
         }
     }
     $this->SetActionMode('Attachment', 'normal', 'standalone');
     return Jaws_HTTPError::Get(404);
 }
Ejemplo n.º 3
0
 /**
  * Switch between dashboards
  *
  * @access  public
  * @return  mixed   Redirect if switched successfully otherwise content of 403 html status code
  */
 function Dashboard()
 {
     if (!$GLOBALS['app']->Session->GetPermission('Users', 'AccessDashboard')) {
         return Jaws_HTTPError::Get(403);
     }
     $layoutModel = $this->gadget->model->load('Layout');
     $layoutModel->InitialLayout('Index.Dashboard');
     Jaws_Header::Location('');
 }
Ejemplo n.º 4
0
 /**
  * Block Agent hook
  *
  * @access  private
  */
 function BlockAgentHook()
 {
     $model = $this->gadget->model->load('Agent');
     $res = $model->IsAgentBlocked($_SERVER["HTTP_USER_AGENT"]);
     if ($res) {
         echo Jaws_HTTPError::Get(403);
         exit;
     }
 }
Ejemplo n.º 5
0
 /**
  * Switch between dashboards
  *
  * @access  public
  * @return  mixed   Redirect if switched successfully otherwise content of 403 html status code
  */
 function Dashboard()
 {
     if (!$GLOBALS['app']->Session->GetPermission('Users', 'AccessDashboard')) {
         return Jaws_HTTPError::Get(403);
     }
     //$user = jaws()->request->fetch('user');
     $user = (int) $GLOBALS['app']->Session->GetAttribute('user');
     $layoutModel = $this->gadget->model->load('Layout');
     $layoutModel->DashboardSwitch($user);
     Jaws_Header::Location('');
 }
Ejemplo n.º 6
0
 /**
  * Build and export data with VCard format
  *
  * @access  public
  * @return  string HTML content with menu and menu items
  */
 function VCardBuild()
 {
     if (!$GLOBALS['app']->Session->Logged()) {
         return Jaws_HTTPError::Get(403);
     }
     require_once JAWS_PATH . 'gadgets/Addressbook/vCard.php';
     $model = $this->gadget->model->load('AddressBook');
     $agModel = $this->gadget->model->load('AddressBookGroup');
     $user = (int) $GLOBALS['app']->Session->GetAttribute('user');
     $ids = jaws()->request->fetch('adr:array');
     $link = $this->gadget->urlMap('AddressBook', array(), true);
     if (empty($ids)) {
         Jaws_Header::Location($link);
         return false;
     }
     $addressItems = $model->GetAddresses($ids, $user);
     if (Jaws_Error::IsError($addressItems) || empty($addressItems)) {
         return Jaws_HTTPError::Get(404);
     }
     $result = '';
     $nVCard = array('LastName', 'FirstName', 'AdditionalNames', 'Prefixes', 'Suffixes');
     foreach ($addressItems as $addressItem) {
         $vCard = new vCard();
         $names = explode(';', $addressItem['name']);
         foreach ($names as $key => $name) {
             $vCard->n($name, $nVCard[$key]);
         }
         $vCard->fn($names[3] . (trim($names[3]) == '' ? '' : ' ') . $names[1] . (trim($names[1]) == '' ? '' : ' ') . $names[0]);
         $vCard->nickname($addressItem['nickname']);
         $vCard->title($addressItem['title']);
         $adrGroups = $agModel->GetGroupNames($addressItem['address_id'], $user);
         $vCard->categories(implode(',', $adrGroups));
         $this->FillVCardTypes($vCard, 'tel', $addressItem['tel_home'], $this->_TelTypes);
         $this->FillVCardTypes($vCard, 'tel', $addressItem['tel_work'], $this->_TelTypes);
         $this->FillVCardTypes($vCard, 'tel', $addressItem['tel_other'], $this->_TelTypes);
         $this->FillVCardTypes($vCard, 'email', $addressItem['email_home'], $this->_EmailTypes);
         $this->FillVCardTypes($vCard, 'email', $addressItem['email_work'], $this->_EmailTypes);
         $this->FillVCardTypes($vCard, 'email', $addressItem['email_other'], $this->_EmailTypes);
         $this->FillVCardTypes($vCard, 'adr', $addressItem['adr_home'], $this->_AdrTypes, '\\n');
         $this->FillVCardTypes($vCard, 'adr', $addressItem['adr_work'], $this->_AdrTypes, '\\n');
         $this->FillVCardTypes($vCard, 'adr', $addressItem['adr_other'], $this->_AdrTypes, '\\n');
         $this->FillVCardTypes($vCard, 'url', $addressItem['url'], null, '\\n');
         $vCard->note($addressItem['notes']);
         $result = $result . $vCard;
     }
     header("Content-Disposition: attachment; filename=\"" . 'address.vcf' . "\"");
     header("Content-type: application/csv");
     header("Content-Length: " . strlen($result));
     header("Pragma: no-cache");
     header("Expires: 0");
     header("Connection: close");
     echo $result;
     exit;
 }
Ejemplo n.º 7
0
Archivo: Group.php Proyecto: uda/jaws
 /**
  * Displays a block of pages belongs to the specified group
  *
  * @access  public
  * @param   mixed   $gid    ID or fast_url of the group (int/string)
  * @param   int     $orderBy
  * @param   int     $limit    limit show pages
  * @return  string  XHTML content
  */
 function GroupPages($gid = 0, $orderBy = 1, $limit = 0)
 {
     if (empty($gid)) {
         $get = $this->gadget->request->fetch(array('gid', 'order'), 'get');
         $gid = Jaws_XSS::defilter($get['gid']);
         $orderBy = $get['order'];
     }
     $pModel = $this->gadget->model->load('Page');
     $gModel = $this->gadget->model->load('Group');
     $group = $gModel->GetGroup($gid);
     if (Jaws_Error::IsError($group) || $group == null) {
         return false;
     }
     if (!$this->gadget->GetPermission('AccessGroup', $group['id'])) {
         return Jaws_HTTPError::Get(403);
     }
     $GLOBALS['app']->Layout->SetTitle($group['title']);
     $GLOBALS['app']->Layout->AddToMetaKeywords($group['meta_keywords']);
     $GLOBALS['app']->Layout->SetDescription($group['meta_description']);
     if (!is_numeric($gid)) {
         $gid = $group['id'];
     }
     $pages = $pModel->GetPages($gid, $limit, $orderBy, null, true);
     if (Jaws_Error::IsError($pages)) {
         return false;
     }
     $tpl = $this->gadget->template->load('StaticPage.html');
     $tpl->SetBlock('group_pages');
     $tpl->SetVariable('title', $group['title']);
     foreach ($pages as $page) {
         $param = array('gid' => empty($group['fast_url']) ? $group['id'] : $group['fast_url'], 'pid' => empty($page['fast_url']) ? $page['base_id'] : $page['fast_url']);
         $link = $this->gadget->urlMap('Pages', $param);
         $tpl->SetBlock('group_pages/item');
         $tpl->SetVariable('page', $page['title']);
         $tpl->SetVariable('link', $link);
         $tpl->ParseBlock('group_pages/item');
     }
     // parsing read-more block if required
     if (!empty($limit) && count($pages) >= $limit && $GLOBALS['app']->requestedActionMode == ACTION_MODE_LAYOUT) {
         $urlParam = array('gid' => empty($group['fast_url']) ? $group['id'] : $group['fast_url'], 'order' => $orderBy);
         // prevent duplicate content via two different url
         if ($orderBy == 1) {
             unset($urlParam['order']);
         }
         $tpl->SetBlock('group_pages/read-more');
         $tpl->SetVariable('url', $this->gadget->urlMap('GroupPages', $urlParam));
         $tpl->SetVariable('read_more', _t('STATICPAGE_GROUP_PAGES_LIST', $group['title']));
         $tpl->ParseBlock('group_pages/read-more');
     }
     $tpl->ParseBlock('group_pages');
     return $tpl->Get();
 }
Ejemplo n.º 8
0
 /**
  * Sitemap XML content
  *
  * @access  public
  * @return  string  XML content
  */
 function SitemapXML()
 {
     header('Content-Type: text/xml; charset=utf-8');
     $model = $this->gadget->model->load('Sitemap');
     $gadget = jaws()->request->fetch('gname', 'get');
     $gadget = Jaws_Gadget::filter($gadget);
     if (empty($gadget)) {
         return $model->GetSitemapXML();
     } else {
         $xml = $model->GetGadgetSitemapXML($gadget);
         if (empty($xml)) {
             return Jaws_HTTPError::Get(404);
         }
         return $xml;
     }
 }
Ejemplo n.º 9
0
 /**
  * Displays a list of blog posts included on the given category
  *
  * @access  public
  * @param   int     $cat    category ID
  * @return  string  XHTML template content
  */
 function ShowCategory($cat = null)
 {
     $cModel = $this->gadget->model->load('Categories');
     $pModel = $this->gadget->model->load('Posts');
     $rqst = jaws()->request->fetch(array('id', 'page'), 'get');
     $page = $rqst['page'];
     if (is_null($page) || $page <= 0) {
         $page = 1;
     }
     if (is_null($cat)) {
         if (empty($rqst['id'])) {
             $catInfo = array('id' => 0, 'name' => _t('BLOG_UNCATEGORIZED'), 'fast_url' => '', 'description' => '', 'meta_keywords' => '', 'meta_description' => '');
         } else {
             $cat = Jaws_XSS::defilter($rqst['id']);
             $catInfo = $cModel->GetCategory($cat);
             if (Jaws_Error::IsError($catInfo) || empty($catInfo)) {
                 return Jaws_HTTPError::Get(404);
             }
             // Check dynamic ACL
             if (!$this->gadget->GetPermission('CategoryAccess', $catInfo['id'])) {
                 return Jaws_HTTPError::Get(403);
             }
         }
     }
     $name = $catInfo['name'];
     $tpl = $this->gadget->template->load('CategoryPosts.html');
     $GLOBALS['app']->Layout->AddHeadLink($this->gadget->urlMap('ShowAtomCategory', array('id' => $cat)), 'alternate', 'application/atom+xml', 'Atom - ' . $name);
     $GLOBALS['app']->Layout->AddHeadLink($this->gadget->urlMap('ShowRSSCategory', array('id' => $cat)), 'alternate', 'application/rss+xml', 'RSS 2.0 - ' . $name);
     $this->SetTitle($name);
     $this->AddToMetaKeywords($catInfo['meta_keywords']);
     $this->SetDescription($catInfo['meta_description']);
     $tpl->SetBlock('view_category');
     $tpl->SetVariable('title', $name);
     $total = $cModel->GetCategoryNumberOfPages($catInfo['id']);
     $limit = $this->gadget->registry->fetch('last_entries_limit');
     $params = array('id' => $cat);
     $tpl->SetVariable('navigation', $this->GetNumberedPageNavigation($page, $limit, $total, 'ShowCategory', $params));
     $entries = $pModel->GetEntriesByCategory($catInfo['id'], $page);
     if (!Jaws_Error::IsError($entries)) {
         foreach ($entries as $entry) {
             $this->ShowEntry($tpl, 'view_category', $entry);
         }
     }
     $tpl->ParseBlock('view_category');
     return $tpl->Get();
 }
Ejemplo n.º 10
0
 /**
  * Display Private Message
  *
  * @access  public
  * @return  void
  */
 function PrivateMessage()
 {
     if (!$GLOBALS['app']->Session->Logged()) {
         return Jaws_HTTPError::Get(401);
     }
     $tpl = $this->gadget->template->load('PrivateMessage.html');
     $tpl->SetBlock('PrivateMessage');
     $tpl->SetVariable('title', $this->gadget->title);
     $model = $this->gadget->model->load('Message');
     $user_id = $GLOBALS['app']->Session->GetAttribute('user');
     $unreadNotifyCount = $model->GetMessagesStatistics($user_id, PrivateMessage_Info::PRIVATEMESSAGE_FOLDER_NOTIFICATIONS, array('read' => 'no'));
     $unreadInboxCount = $model->GetMessagesStatistics($user_id, PrivateMessage_Info::PRIVATEMESSAGE_FOLDER_INBOX, array('read' => 'no'));
     $draftMessageCount = $model->GetMessagesStatistics($user_id, PrivateMessage_Info::PRIVATEMESSAGE_FOLDER_DRAFT);
     if ($unreadNotifyCount > 0) {
         $tpl->SetVariable('notifications', _t('PRIVATEMESSAGE_NOTIFICATIONS', '(' . $unreadNotifyCount . ')'));
     } else {
         $tpl->SetVariable('notifications', _t('PRIVATEMESSAGE_NOTIFICATIONS'));
     }
     if ($unreadInboxCount > 0) {
         $tpl->SetVariable('inbox', _t('PRIVATEMESSAGE_INBOX', '(' . $unreadInboxCount . ')'));
     } else {
         $tpl->SetVariable('inbox', _t('PRIVATEMESSAGE_INBOX'));
     }
     if ($draftMessageCount > 0) {
         $tpl->SetVariable('draft', _t('PRIVATEMESSAGE_DRAFT', '(' . $draftMessageCount . ')'));
     } else {
         $tpl->SetVariable('draft', _t('PRIVATEMESSAGE_DRAFT'));
     }
     $tpl->SetVariable('archived', _t('PRIVATEMESSAGE_ARCHIVED'));
     $tpl->SetVariable('outbox', _t('PRIVATEMESSAGE_OUTBOX'));
     $tpl->SetVariable('trash', _t('PRIVATEMESSAGE_TRASH'));
     $tpl->SetVariable('compose_message', _t('PRIVATEMESSAGE_COMPOSE_MESSAGE'));
     $tpl->SetVariable('all_messages', _t('PRIVATEMESSAGE_ALL_MESSAGES'));
     $tpl->SetVariable('compose_message_url', $this->gadget->urlMap('Compose'));
     $tpl->SetVariable('all_messages_url', $this->gadget->urlMap('Messages'));
     $tpl->SetVariable('notifications_url', $this->gadget->urlMap('Messages', array('folder' => PrivateMessage_Info::PRIVATEMESSAGE_FOLDER_NOTIFICATIONS)));
     $tpl->SetVariable('inbox_url', $this->gadget->urlMap('Messages', array('folder' => PrivateMessage_Info::PRIVATEMESSAGE_FOLDER_INBOX)));
     $tpl->SetVariable('archived_url', $this->gadget->urlMap('Messages', array('folder' => PrivateMessage_Info::PRIVATEMESSAGE_FOLDER_ARCHIVED)));
     $tpl->SetVariable('draft_url', $this->gadget->urlMap('Messages', array('folder' => PrivateMessage_Info::PRIVATEMESSAGE_FOLDER_DRAFT)));
     $tpl->SetVariable('outbox_url', $this->gadget->urlMap('Messages', array('folder' => PrivateMessage_Info::PRIVATEMESSAGE_FOLDER_OUTBOX)));
     $tpl->SetVariable('trash_url', $this->gadget->urlMap('Messages', array('folder' => PrivateMessage_Info::PRIVATEMESSAGE_FOLDER_TRASH)));
     $tpl->ParseBlock('PrivateMessage');
     return $tpl->Get();
 }
Ejemplo n.º 11
0
 /**
  * Displays a block of pages belongs to the specified group
  *
  * @access  public
  * @param   mixed   $gid    ID or fast_url of the group (int/string)
  * @param   int     $orderBy
  * @param   int     $limit    limit show pages
  * @return  string  XHTML content
  */
 function GroupPages($gid = 0, $orderBy = 1, $limit = 0)
 {
     if (empty($gid)) {
         $get = $this->gadget->request->fetch(array('gid', 'order'), 'get');
         $gid = Jaws_XSS::defilter($get['gid']);
         $orderBy = $get['order'];
     }
     $pModel = $this->gadget->model->load('Page');
     $gModel = $this->gadget->model->load('Group');
     $group = $gModel->GetGroup($gid);
     if (Jaws_Error::IsError($group) || $group == null) {
         return false;
     }
     if (!$this->gadget->GetPermission('AccessGroup', $group['id'])) {
         return Jaws_HTTPError::Get(403);
     }
     $GLOBALS['app']->Layout->SetTitle($group['title']);
     $GLOBALS['app']->Layout->AddToMetaKeywords($group['meta_keywords']);
     $GLOBALS['app']->Layout->SetDescription($group['meta_description']);
     if (!is_numeric($gid)) {
         $gid = $group['id'];
     }
     $pages = $pModel->GetPages($gid, $limit, $orderBy, null, true);
     if (Jaws_Error::IsError($pages)) {
         return false;
     }
     $tpl = $this->gadget->template->load('StaticPage.html');
     $tpl->SetBlock('group_pages');
     $tpl->SetVariable('title', $group['title']);
     foreach ($pages as $page) {
         $param = array('gid' => empty($group['fast_url']) ? $group['id'] : $group['fast_url'], 'pid' => empty($page['fast_url']) ? $page['base_id'] : $page['fast_url']);
         $link = $this->gadget->urlMap('Pages', $param);
         $tpl->SetBlock('group_pages/item');
         $tpl->SetVariable('page', $page['title']);
         $tpl->SetVariable('link', $link);
         $tpl->ParseBlock('group_pages/item');
     }
     $tpl->ParseBlock('group_pages');
     return $tpl->Get();
 }
Ejemplo n.º 12
0
 /**
  * Generates and returns Author Page
  * 
  * @access  public
  * @return  string  XHTML template content
  */
 function ViewAuthorPage()
 {
     $post = jaws()->request->fetch(array('id', 'page'), 'get');
     $page = $post['page'];
     if (is_null($page) || $page <= 0) {
         $page = 1;
     }
     $user = $post['id'];
     if (!isset($user) || empty($user)) {
         return false;
     }
     $whereArray = null;
     if (is_numeric($user)) {
         $whereArray = array(array('blog.user_id', $user, '='));
     } else {
         $whereArray = array(array('users.username', $user, '='));
     }
     $pModel = $this->gadget->model->load('Posts');
     $aModel = $this->gadget->model->load('AuthorPosts');
     $entries = $pModel->GetEntriesAsPage(null, $page, $whereArray);
     if (!Jaws_Error::IsError($entries) && !empty($entries)) {
         $tpl = $this->gadget->template->load('AuthorPosts.html');
         $tpl->SetBlock('view_author');
         // set author nickname
         $firstEntry = reset($entries);
         $this->SetTitle($firstEntry['nickname']);
         $tpl->SetVariable('title', $firstEntry['nickname']);
         $total = $aModel->GetAuthorNumberOfPages($user);
         $limit = $this->gadget->registry->fetch('last_entries_limit');
         $params = array('id' => $user);
         $tpl->SetVariable('navigation', $this->GetNumberedPageNavigation($page, $limit, $total, 'ViewAuthorPage', $params));
         foreach ($entries as $entry) {
             $this->ShowEntry($tpl, 'view_author', $entry);
         }
         $tpl->ParseBlock('view_author');
         return $tpl->Get();
     } else {
         return Jaws_HTTPError::Get(404);
     }
 }
Ejemplo n.º 13
0
 /**
  * Returns the Jaws/component version
  *
  * @access  public
  * @return  string  Version as plain text 
  */
 function Version()
 {
     if ($this->gadget->registry->fetch('versions_remote_access') != 'true') {
         return Jaws_HTTPError::Get(403);
     }
     $get = jaws()->request->fetch(array('type', 'component'));
     $version = '0';
     switch ((int) $get['type']) {
         case 0:
             $version = JAWS_VERSION;
             break;
         case 1:
             $objGadget = Jaws_Gadget::getInstance($get['component']);
             $version = Jaws_Error::isError($objGadget) ? Jaws_HTTPError::Get(404) : $objGadget->version;
             break;
         case 2:
             $objPlugin = $GLOBALS['app']->LoadPlugin($get['componente']);
             $version = Jaws_Error::isError($objPlugin) ? Jaws_HTTPError::Get(404) : $objPlugin->version;
             break;
     }
     return $version;
 }
Ejemplo n.º 14
0
 /**
  * Displays the list of Public Address Book items for selected user
  *
  * @access  public
  * @return  string HTML content with menu and menu items
  */
 function UserAddress()
 {
     if (!$GLOBALS['app']->Session->Logged() || !jaws()->request->fetch('uid')) {
         return Jaws_HTTPError::Get(403);
     }
     $uid = jaws()->request->fetch('uid');
     $usrModel = new Jaws_User();
     $user = $usrModel->GetUser($uid, true, true);
     if (Jaws_Error::IsError($user) || empty($user)) {
         return Jaws_HTTPError::Get(404);
     }
     $model = $this->gadget->model->load('AddressBook');
     $addressItems = $model->GetAddressList($user['id'], 0, true);
     if (Jaws_Error::IsError($addressItems) || !isset($addressItems)) {
         return $addressItems->getMessage();
         // TODO: Show intelligible message
     }
     $this->SetTitle($this->gadget->title);
     $tpl = $this->gadget->template->load('UserAddress.html');
     $tpl->SetBlock("address_list");
     $tpl->SetVariable('title', _t('ADDRESSBOOK_USER_ADDRESS_TITLE', $user['nickname']));
     $tpl->SetVariable('lbl_name', _t('ADDRESSBOOK_ITEMS_NAME'));
     $tpl->SetVariable('lbl_title', _t('ADDRESSBOOK_ITEMS_TITLE'));
     $tpl->SetVariable('back_to_my_adr', _t('ADDRESSBOOK_BACK_TO_MY_ADDRESS'));
     $tpl->SetVariable('back_to_my_adr_link', $this->gadget->urlMap('AddressBook'));
     foreach ($addressItems as $addressItem) {
         $tpl->SetBlock("address_list/item1");
         $names = explode(';', $addressItem['name']);
         foreach ($names as $key => $name) {
             $tpl->SetVariable('name' . $key, $name);
         }
         $tpl->SetVariable('name', str_replace(';', ' ', $addressItem['name']));
         $tpl->SetVariable('title', $addressItem['title']);
         $tpl->SetVariable('view_url', $this->gadget->urlMap('View', array('id' => $addressItem['id'])));
         $tpl->ParseBlock("address_list/item1");
     }
     $tpl->ParseBlock('address_list');
     return $tpl->Get();
 }
Ejemplo n.º 15
0
 /**
  * Builds password recovery UI
  *
  * @access  public
  * @return  string  XHTML content
  */
 function ForgotLogin()
 {
     if ($this->gadget->registry->fetch('password_recovery') !== 'true') {
         return Jaws_HTTPError::Get(404);
     }
     // Load the template
     $tpl = $this->gadget->template->load('ForgotLogin.html');
     $tpl->SetBlock('forgot');
     $tpl->SetVariable('base_script', BASE_SCRIPT);
     $tpl->SetVariable('title', _t('USERS_FORGOT_REMEMBER'));
     $tpl->SetVariable('info', _t('USERS_FORGOT_REMEMBER_INFO'));
     $tpl->SetVariable('email', _t('GLOBAL_EMAIL'));
     $tpl->SetVariable('remember', _t('GLOBAL_SUBMIT'));
     //captcha
     $mPolicy = Jaws_Gadget::getInstance('Policy')->action->load('Captcha');
     $mPolicy->loadCaptcha($tpl, 'forgot');
     if ($response = $GLOBALS['app']->Session->PopResponse('Users.ForgotLogin')) {
         $tpl->SetVariable('type', $response['type']);
         $tpl->SetVariable('text', $response['text']);
     }
     $tpl->ParseBlock('forgot');
     return $tpl->Get();
 }
Ejemplo n.º 16
0
 /**
  * Import data with VCard format from file
  *
  * @access  public
  * @return  string HTML content with menu and menu items
  */
 function VCardImportFile()
 {
     if (!$GLOBALS['app']->Session->Logged()) {
         return Jaws_HTTPError::Get(403);
     }
     require_once JAWS_PATH . 'gadgets/Addressbook/vCard.php';
     if (empty($_FILES) || !is_array($_FILES)) {
         $GLOBALS['app']->Session->PushResponse(_t('ADDRESSBOOK_RESULT_ERROR_IMPORT_PLEASE_SELECT_FILE'), 'AddressBook.Import', RESPONSE_ERROR);
         Jaws_Header::Location($this->gadget->urlMap('VCardImport'));
     }
     try {
         $vCard = new vCard($_FILES['vcard_file']['tmp_name'], false, array('Collapse' => false));
         $model = $this->gadget->model->load('AddressBook');
         if (count($vCard) == 0) {
             $GLOBALS['app']->Session->PushResponse(_t('ADDRESSBOOK_RESULT_ERROR_VCARD_DATA_NOT_FOUND'), 'AddressBook.Import', RESPONSE_ERROR);
             Jaws_Header::Location($this->gadget->urlMap('VCardImport'));
         } elseif (count($vCard) == 1) {
             $result = $this->PrepareForImport($vCard);
             if ($result) {
                 $adrID = $model->InsertAddress($result);
             }
         } else {
             foreach ($vCard as $Index => $vCardPart) {
                 $result = $this->PrepareForImport($vCardPart);
                 if ($result) {
                     $adrID = $model->InsertAddress($result);
                 }
             }
         }
     } catch (Exception $e) {
         $GLOBALS['app']->Session->PushResponse($e->getMessage(), 'AddressBook.Import', RESPONSE_ERROR);
         // TODO: Translate Messages
         Jaws_Header::Location($this->gadget->urlMap('VCardImport'));
     }
     $GLOBALS['app']->Session->PushResponse(_t('ADDRESSBOOK_RESULT_IMPORT_COMPLETED'), 'AddressBook');
     Jaws_Header::Location($this->gadget->urlMap('AddressBook'));
 }
Ejemplo n.º 17
0
 /**
  * Loads layout template
  *
  * @access  public
  * @param   string  $layout_path  Optional layout file path
  * @param   string  $layout_file  Optional layout file name
  * @return  void
  */
 function Load($layout_path = '', $layout_file = '')
 {
     if ($this->attributes['site_status'] == 'disabled' && (JAWS_SCRIPT != 'admin' || $GLOBALS['app']->Session->Logged()) && !$GLOBALS['app']->Session->IsSuperAdmin()) {
         $data = Jaws_HTTPError::Get(503);
         terminate($data, 503);
     }
     $favicon = $this->attributes['site_favicon'];
     if (!empty($favicon)) {
         switch (pathinfo(basename($favicon), PATHINFO_EXTENSION)) {
             case 'svg':
                 $this->AddHeadLink($favicon, 'icon', 'image/svg');
                 break;
             case 'png':
                 $this->AddHeadLink($favicon, 'icon', 'image/png');
                 break;
             case 'ico':
                 $this->AddHeadLink($favicon, 'icon', 'image/vnd.microsoft.icon');
                 break;
             case 'gif':
                 $this->AddHeadLink($favicon, 'icon', 'image/gif');
                 break;
         }
     }
     $this->AddScriptLink('libraries/jquery/jquery.js?' . JAWS_VERSION);
     $this->AddScriptLink('include/Jaws/Resources/Ajax.js?' . JAWS_VERSION);
     if (empty($layout_path)) {
         $theme = $GLOBALS['app']->GetTheme();
         if (!$theme['exists']) {
             Jaws_Error::Fatal('Theme ' . $theme['name'] . ' doesn\'t exists.');
         }
         $layout_path = $theme['path'];
         $this->IndexLayout = $GLOBALS['app']->mainIndex && $theme['index'];
         if (empty($layout_file)) {
             $layout_file = $this->IndexLayout ? 'index.html' : 'layout.html';
         }
     }
     $this->_Template = new Jaws_Template();
     $this->_Template->Load($layout_file, $layout_path);
     $this->_Template->SetBlock('layout');
     $direction = _t('GLOBAL_LANG_DIRECTION');
     $dir = $direction == 'rtl' ? ".{$direction}" : '';
     $browser = $GLOBALS['app']->GetBrowserFlag();
     $browser = empty($browser) ? '' : ".{$browser}";
     $base_url = $GLOBALS['app']->GetSiteURL('/');
     $this->_Template->SetVariable('base_url', $base_url);
     $this->_Template->SetVariable('skip_to_content', _t('GLOBAL_SKIP_TO_CONTENT'));
     $this->_Template->SetVariable('.dir', $dir);
     $this->_Template->SetVariable('.browser', $browser);
     $this->_Template->SetVariable('site-url', $base_url);
     $this->_Template->SetVariable('site-direction', $direction);
     $this->_Template->SetVariable('site-name', $this->attributes['site_name']);
     $this->_Template->SetVariable('site-slogan', $this->attributes['site_slogan']);
     $this->_Template->SetVariable('site-comment', $this->attributes['site_comment']);
     $this->_Template->SetVariable('site-author', $this->attributes['site_author']);
     $this->_Template->SetVariable('site-license', $this->attributes['site_license']);
     $this->_Template->SetVariable('site-copyright', $this->attributes['site_copyright']);
     $cMetas = @unserialize($this->attributes['site_custom_meta']);
     if (!empty($cMetas)) {
         foreach ($cMetas as $cMeta) {
             $this->AddHeadMeta($cMeta[0], $cMeta[1]);
         }
     }
     $this->_Template->SetVariable('encoding', 'utf-8');
     $this->_Template->SetVariable('loading-message', _t('GLOBAL_LOADING'));
 }
Ejemplo n.º 18
0
 /**
  * Send a message
  *
  * @access  public
  * @return  void
  */
 function SendMessage()
 {
     if (!$GLOBALS['app']->Session->Logged()) {
         return Jaws_HTTPError::Get(401);
     }
     $this->gadget->CheckPermission('SendMessage');
     $post = jaws()->request->fetch(array('id', 'recipient_users', 'recipient_groups', 'folder', 'subject', 'body', 'attachments:array', 'is_draft:bool'), 'post');
     $post['body'] = jaws()->request->strip_crlf($post['body']);
     $user = $GLOBALS['app']->Session->GetAttribute('user');
     $model = $this->gadget->model->load('Message');
     if (empty($post['folder'])) {
         $post['folder'] = $post['is_draft'] ? PrivateMessage_Info::PRIVATEMESSAGE_FOLDER_DRAFT : PrivateMessage_Info::PRIVATEMESSAGE_FOLDER_INBOX;
     }
     $message_id = $model->SendMessage($user, $post);
     $url = $this->gadget->urlMap('Messages', array('folder' => PrivateMessage_Info::PRIVATEMESSAGE_FOLDER_INBOX));
     if (Jaws_Error::IsError($message_id)) {
         $GLOBALS['app']->Session->PushResponse($message_id->getMessage(), 'PrivateMessage.Compose', RESPONSE_ERROR);
     } else {
         if ($post['is_draft']) {
             $GLOBALS['app']->Session->PushResponse(_t('PRIVATEMESSAGE_DRAFT_SAVED'), 'PrivateMessage.Compose', RESPONSE_NOTICE, array('is_draft' => true, 'message_id' => $message_id));
         } else {
             $GLOBALS['app']->Session->PushResponse(_t('PRIVATEMESSAGE_MESSAGE_SEND'), 'PrivateMessage.Compose', RESPONSE_NOTICE, array('url' => $url));
         }
     }
     Jaws_Header::Location($url, 'PrivateMessage.Compose');
 }
Ejemplo n.º 19
0
    $ReqGadget = null;
    $ReqAction = null;
}
// set requested in front-end first/home page
$GLOBALS['app']->mainIndex = $IsIndex;
// Init layout...
$GLOBALS['app']->InstanceLayout();
$GLOBALS['app']->Layout->Load();
// Run auto-load methods before standalone actions too
$GLOBALS['app']->RunAutoload();
if (empty($ReqError)) {
    $ReqResult = '';
    if (!empty($objAction)) {
        // set in main request
        $GLOBALS['app']->inMainRequest = true;
        $ReqResult = $objAction->Execute($ReqAction);
        if (Jaws_Error::isError($ReqResult)) {
            $ReqResult = $ReqResult->GetMessage();
        }
        $GLOBALS['app']->inMainRequest = false;
        // we must check type of action after execute, because gadget can change it at runtime
        $IsReqActionStandAlone = $objAction->IsStandAlone($ReqAction);
    }
} else {
    $ReqResult = Jaws_HTTPError::Get($ReqError);
}
if (!$IsReqActionStandAlone) {
    $GLOBALS['app']->Layout->Populate($ReqResult, $AccessToWebsiteDenied);
    $ReqResult = $GLOBALS['app']->Layout->Get();
}
terminate($ReqResult);
Ejemplo n.º 20
0
 /**
  * Redirects request to banner's target
  *
  * @access  public
  * @return  mixed    Void if Success, 404  XHTML template content on Failure
  */
 function Click()
 {
     $model = $this->gadget->model->load('Banners');
     $id = (int) jaws()->request->fetch('id', 'get');
     $banner = $model->GetBanners($id);
     if (!Jaws_Error::IsError($banner) && !empty($banner)) {
         $click = $model->ClickBanner($banner[0]['id']);
         if (!Jaws_Error::IsError($click)) {
             $link = $banner[0]['url'];
             Jaws_Header::Location($link);
         }
     } else {
         return Jaws_HTTPError::Get(404);
     }
 }
Ejemplo n.º 21
0
Archivo: Profile.php Proyecto: 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();
 }
Ejemplo n.º 22
0
 /**
  * Displays not editable version of one address
  *
  * @access  public
  * @return  string HTML content with menu and menu items
  */
 function View()
 {
     if (!$GLOBALS['app']->Session->Logged()) {
         return Jaws_HTTPError::Get(403);
     }
     $id = (int) jaws()->request->fetch('id');
     // TODO: Check this ID for Me, And Can I Edit Or View This?!
     if ($id == 0) {
         return false;
     }
     $model = $this->gadget->model->load('AddressBook');
     $info = $model->GetAddressInfo($id);
     if (Jaws_Error::IsError($info)) {
         return $info->getMessage();
         // TODO: Show intelligible message
     }
     if (!isset($info)) {
         return Jaws_HTTPError::Get(404);
     }
     if ($info['user'] != $GLOBALS['app']->Session->GetAttribute('user') && $info['public'] == false) {
         return Jaws_HTTPError::Get(403);
     }
     $this->SetTitle(_t('ADDRESSBOOK_ITEMS_VIEW_TITLE'));
     $tpl = $this->gadget->template->load('ViewAddress.html');
     $tpl->SetBlock("address");
     $tpl->SetVariable('top_title', _t('ADDRESSBOOK_ITEMS_VIEW_TITLE'));
     $tpl->SetVariable('id', $info['id']);
     $tpl->SetVariable('action', 'UpdateAddress');
     $tpl->SetVariable('lbl_name0', _t('ADDRESSBOOK_ITEMS_LASTNAME'));
     $tpl->SetVariable('lbl_name1', _t('ADDRESSBOOK_ITEMS_FIRSTNAME'));
     $tpl->SetVariable('lbl_nickname', _t('ADDRESSBOOK_ITEMS_NICKNAME'));
     $tpl->SetVariable('lbl_title', _t('ADDRESSBOOK_ITEMS_TITLE'));
     $tpl->SetVariable('lbl_notes', _t('ADDRESSBOOK_ITEMS_NOTES'));
     $tpl->SetVariable('nickname', $info['nickname']);
     $tpl->SetVariable('title', $info['title']);
     $tpl->SetVariable('notes', $info['notes']);
     $names = explode(';', $info['name']);
     foreach ($names as $key => $name) {
         $tpl->SetVariable('name' . $key, $name);
     }
     if (empty($info['image'])) {
         $current_image = $GLOBALS['app']->getSiteURL('/gadgets/AddressBook/Resources/images/photo128px.png');
     } else {
         $current_image = $GLOBALS['app']->getDataURL() . "addressbook/image/" . $info['image'];
         $current_image .= !empty($info['updatetime']) ? "?" . $info['updatetime'] . "" : '';
     }
     $tpl->SetVariable('image_src', $current_image);
     // Tel
     $this->GetItemsLable($tpl, 'item', $info['tel_home'], $this->_TelTypes);
     $this->GetItemsLable($tpl, 'item', $info['tel_work'], $this->_TelTypes);
     $this->GetItemsLable($tpl, 'item', $info['tel_other'], $this->_TelTypes);
     // Email
     $this->GetItemsLable($tpl, 'item', $info['email_home'], $this->_EmailTypes);
     $this->GetItemsLable($tpl, 'item', $info['email_work'], $this->_EmailTypes);
     $this->GetItemsLable($tpl, 'item', $info['email_other'], $this->_EmailTypes);
     // URL
     $this->GetItemsLable($tpl, 'item', $info['url'], null, '\\n');
     if ($info['public']) {
         $tpl->SetBlock('address/selected');
         $tpl->SetVariable('lbl_is_public', _t('ADDRESSBOOK_ITEMS_IS_PUBLIC'));
         $tpl->ParseBlock('address/selected');
     }
     $agModel = $this->gadget->model->load('AddressBookGroup');
     $agData = $agModel->GetData($info['id'], $info['user']);
     if (isset($agData)) {
         foreach ($agData as $gInfo) {
             $tpl->SetBlock('address/group');
             $tpl->SetVariable('lbl_group', $gInfo['name']);
             $tpl->ParseBlock('address/group');
         }
     }
     $tpl->SetVariable('menubar', $this->MenuBar(''));
     $tpl->SetBlock('address/actions');
     if ($info['user'] == $GLOBALS['app']->Session->GetAttribute('user')) {
         $tpl->SetBlock('address/actions/action');
         $tpl->SetVariable('action_lbl', _t('GLOBAL_EDIT'));
         $tpl->SetVariable('action_url', $this->gadget->urlMap('EditAddress', array('id' => $info['id'])));
         $tpl->ParseBlock('address/actions/action');
     } else {
         $usrModel = new Jaws_User();
         $user = $usrModel->GetUser((int) $info['user']);
         if (!Jaws_Error::IsError($user) && !empty($user)) {
             $tpl->SetBlock('address/actions/action');
             $tpl->SetVariable('action_lbl', _t('ADDRESSBOOK_VIEW_ALL_ADDREESS_USER'));
             $tpl->SetVariable('action_url', $this->gadget->urlMap('UserAddress', array('uid' => $user['username'])));
             $tpl->ParseBlock('address/actions/action');
         }
     }
     $tpl->ParseBlock('address/actions');
     $tpl->ParseBlock('address');
     return $tpl->Get();
 }
Ejemplo n.º 23
0
 /**
  * Look for a term and prints it
  *
  * @access  public
  * @return  string  XHTML template content
  */
 function ViewTerm()
 {
     $term = jaws()->request->fetch('term', 'get');
     $term = Jaws_XSS::defilter($term);
     $model = $this->gadget->model->load('Term');
     $term = $model->GetTerm($term);
     if (!Jaws_Error::IsError($term) && isset($term['term'])) {
         $this->SetTitle($term['term']);
         $tpl = $this->gadget->template->load('ViewTerm.html');
         $tpl->SetBlock('definition');
         $tpl->SetVariable('title', $this->gadget->title);
         $date = Jaws_Date::getInstance();
         $tpl->SetBlock('definition/term');
         $tpl->SetVariable('term', $term['term']);
         $tid = empty($term['fast_url']) ? $term['id'] : $term['fast_url'];
         $tpl->SetVariable('url', $this->gadget->urlMap('ViewTerm', array('term' => $tid)));
         $tpl->SetVariable('description', $this->gadget->ParseText($term['description']));
         $tpl->SetVariable('created_in', _t('GLOBAL_CREATETIME'));
         $tpl->SetVariable('updated_in', _t('GLOBAL_UPDATETIME'));
         $tpl->SetVariable('createtime', $date->Format($term['createtime']));
         $tpl->SetVariable('updatetime', $date->Format($term['updatetime']));
         $tpl->ParseBlock('definition/term');
         $tpl->ParseBlock('definition');
     } else {
         return Jaws_HTTPError::Get(404);
     }
     return $tpl->Get();
 }
Ejemplo n.º 24
0
 /**
  * Save changes on an edited blog entry and shows the entries list on admin section
  *
  * @access  public
  */
 function SaveEditEntry()
 {
     $names = array('id', 'edit_timestamp:array', 'pubdate', 'categories:array', 'title', 'fasturl', 'meta_keywords', 'meta_desc', 'tags', 'deleteImage', 'allow_comments:array', 'published', 'trackback_to');
     $post = jaws()->request->fetch($names, 'post');
     $content = jaws()->request->fetch(array('summary_block', 'text_block'), 'post', 'strip_crlf');
     $post['trackback_to'] = str_replace("\r\n", "\n", $post['trackback_to']);
     $pModel = $this->gadget->model->loadAdmin('Posts');
     $tModel = $this->gadget->model->loadAdmin('Trackbacks');
     $id = (int) $post['id'];
     $pubdate = null;
     if (isset($post['edit_timestamp']) && $post['edit_timestamp'][0] == 'yes') {
         $pubdate = $post['pubdate'];
     }
     $post['categories'] = !empty($post['categories']) ? $post['categories'] : array();
     foreach ($post['categories'] as $cat) {
         if (!$this->gadget->GetPermission('CategoryManage', $cat)) {
             return Jaws_HTTPError::Get(403);
         }
     }
     // Upload blog image
     $image = false;
     if ($post['deleteImage'] == 'false') {
         $image = null;
         if (count($_FILES) > 0 && !empty($_FILES['image_file']['name'])) {
             $targetDir = JAWS_DATA . 'blog' . DIRECTORY_SEPARATOR . 'images' . DIRECTORY_SEPARATOR;
             $res = Jaws_Utils::UploadFiles($_FILES, $targetDir, 'jpg,gif,png,jpeg,bmp', false);
             if (Jaws_Error::IsError($res)) {
                 $GLOBALS['app']->Session->PushLastResponse($res->getMessage(), RESPONSE_ERROR);
             } elseif (empty($res)) {
                 $GLOBALS['app']->Session->PushLastResponse(_t('GLOBAL_ERROR_UPLOAD_4'), RESPONSE_ERROR);
             } else {
                 $image = $res['image_file'][0]['host_filename'];
                 // Delete old image
                 $model = $this->gadget->model->load('Posts');
                 $blogEntry = $model->GetEntry($id);
                 if (!empty($blogEntry['image'])) {
                     Jaws_Utils::Delete($targetDir . $blogEntry['image']);
                 }
             }
         }
     } else {
         // Delete old image
         $model = $this->gadget->model->load('Posts');
         $blogEntry = $model->GetEntry($id);
         if (!empty($blogEntry['image'])) {
             $targetDir = JAWS_DATA . 'blog' . DIRECTORY_SEPARATOR . 'images' . DIRECTORY_SEPARATOR;
             Jaws_Utils::Delete($targetDir . $blogEntry['image']);
         }
     }
     $pModel->UpdateEntry($id, $post['categories'], $post['title'], $content['summary_block'], $content['text_block'], $image, $post['fasturl'], $post['meta_keywords'], $post['meta_desc'], $post['tags'], isset($post['allow_comments'][0]), $post['trackback_to'], $post['published'], $pubdate);
     if (!Jaws_Error::IsError($id)) {
         if ($this->gadget->registry->fetch('trackback') == 'true') {
             $to = explode("\n", $post['trackback_to']);
             $link = $this->gadget->urlMap('SingleView', array('id' => $id), true);
             $title = $post['title'];
             $text = $content['text_block'];
             if (Jaws_UTF8::strlen($text) > 250) {
                 $text = Jaws_UTF8::substr($text, 0, 250) . '...';
             }
             $tModel->SendTrackback($title, $text, $link, $to);
         }
     }
     Jaws_Header::Location(BASE_SCRIPT . '?gadget=Blog&action=EditEntry&id=' . $id);
 }
Ejemplo n.º 25
0
 /**
  * Delete Group
  *
  * @access  public
  */
 function DeleteGroup()
 {
     if (!$GLOBALS['app']->Session->Logged()) {
         return Jaws_HTTPError::Get(403);
     }
     $gids = jaws()->request->fetch('gid:array');
     $model = $this->gadget->model->load('Groups');
     $result = $model->DeleteGroups($gids, (int) $GLOBALS['app']->Session->GetAttribute('user'));
     if (Jaws_Error::IsError($result)) {
         $GLOBALS['app']->Session->PushResponse($result->getMessage(), 'AddressBook.Groups', RESPONSE_ERROR);
     } else {
         $GLOBALS['app']->Session->PushResponse(_t('ADDRESSBOOK_RESULT_DELETE_GROUP_COMPLETE'), 'AddressBook.Groups');
     }
     Jaws_Header::Location($this->gadget->urlMap('ManageGroups'), 'AddressBook.Groups');
 }
Ejemplo n.º 26
0
 /**
  * Display a Tag
  *
  * @access  public
  * @return  string  XHTML template content
  */
 function ViewTag()
 {
     $get = jaws()->request->fetch(array('tag', 'tagged_gadget', 'page', 'user'), 'get');
     $tag = $get['tag'];
     $gadget = $get['tagged_gadget'];
     $user = (int) $get['user'];
     if (!empty($user) && $user != $GLOBALS['app']->Session->GetAttribute('user')) {
         return Jaws_HTTPError::Get(403);
     }
     $page = $get['page'];
     if (is_null($page) || !is_numeric($page) || $page <= 0) {
         $page = 1;
     }
     $limit = (int) $this->gadget->registry->fetch('tag_results_limit');
     if (empty($limit)) {
         $limit = 10;
     }
     $tagsModel = $this->gadget->model->load('Tags');
     // Fetch tag references count(for paging)
     $referencesCount = $tagsModel->GetTagsCount($gadget, $tag, $user);
     $references = array();
     if ($referencesCount > 0) {
         // Fetch tag references
         $references = $tagsModel->GetTags($gadget, $tag, $user, $limit, ($page - 1) * $limit);
         if (Jaws_Error::IsError($references)) {
             return false;
         }
     }
     $gadgetReferences = array();
     // grouping references by gadget for one time call hook per gadget
     foreach ($references as $reference) {
         $gadgetReferences[$reference['gadget']][$reference['action']][] = $reference['reference'];
     }
     $tpl = $this->gadget->template->load('Tag.html');
     $tpl->SetBlock('tag');
     $tpl->SetVariable('title', _t('TAGS_VIEW_TAG', $tag));
     // page navigation
     $this->GetPagesNavigation($tpl, 'tag', $page, $limit, $referencesCount, _t('TAGS_TAG_ITEM_COUNT', $referencesCount), 'ViewTag', array('tag' => $tag));
     if (count($references) > 2) {
         $tpl->SetBlock('tag/subtitle');
         $tpl->SetVariable('text', _t('SEARCH_RESULTS_SUBTITLE', $referencesCount, $tag));
         $tpl->ParseBlock('tag/subtitle');
     }
     $objDate = Jaws_Date::getInstance();
     $max_result_len = (int) $this->gadget->registry->fetch('max_result_len');
     if (empty($max_result_len)) {
         $max_result_len = 500;
     }
     // call gadget hook
     foreach ($gadgetReferences as $gadget => $action_references) {
         // load gadget
         $objGadget = Jaws_Gadget::getInstance($gadget);
         if (Jaws_Error::IsError($objGadget)) {
             continue;
         }
         // load hook
         $objHook = $objGadget->hook->load('Tags');
         if (Jaws_Error::IsError($objHook)) {
             continue;
         }
         foreach ($action_references as $action => $references) {
             // call execute method
             $result = $objHook->Execute($action, $references);
             if (!Jaws_Error::IsError($result) && !empty($result)) {
                 $tpl->SetBlock('tags/gadget');
                 $tpl->SetVariable('gadget_result', _t('SEARCH_RESULTS_IN_GADGETS', count($result), 'TEST', $objGadget->title));
                 $tpl->ParseBlock('tags/gadget');
                 foreach ($result as $reference) {
                     $tpl->SetBlock('tag/tag_item');
                     $tpl->SetVariable('title', $reference['title']);
                     $tpl->SetVariable('url', $reference['url']);
                     $tpl->SetVariable('target', @$reference['outer'] ? '_blank' : '_self');
                     $tpl->SetVariable('image', $reference['image']);
                     if (!isset($reference['parse_text']) || $reference['parse_text']) {
                         $reference['snippet'] = $this->gadget->ParseText($reference['snippet'], $gadget);
                     }
                     if (!isset($reference['strip_tags']) || $reference['strip_tags']) {
                         $reference['snippet'] = strip_tags($reference['snippet']);
                     }
                     $reference['snippet'] = Jaws_UTF8::substr($reference['snippet'], 0, $max_result_len);
                     $tpl->SetVariable('snippet', $reference['snippet']);
                     $tpl->SetVariable('date', $objDate->Format($reference['date']));
                     $tpl->ParseBlock('tag/tag_item');
                 }
             }
         }
     }
     $tpl->ParseBlock('tag');
     return $tpl->Get();
 }
Ejemplo n.º 27
0
Archivo: admin.php Proyecto: uda/jaws
$GLOBALS['app']->Session->CheckPermission('ControlPanel', 'default_admin');
if (Jaws_Gadget::IsGadgetEnabled($ReqGadget)) {
    $GLOBALS['app']->Session->CheckPermission($ReqGadget, 'default_admin');
    $objAction = Jaws_Gadget::getInstance($ReqGadget)->action->loadAdmin();
    if (Jaws_Error::IsError($objAction)) {
        Jaws_Error::Fatal("Error loading gadget: {$ReqGadget}");
    }
    $ReqAction = empty($ReqAction) ? $objAction->gadget->default_admin_action : $ReqAction;
    // set requested gadget/action
    $GLOBALS['app']->mainGadget = $ReqGadget;
    $GLOBALS['app']->mainAction = $ReqAction;
    // Init layout
    $GLOBALS['app']->InstanceLayout();
    // check referrer host
    if (!$GLOBALS['app']->Session->extraCheck()) {
        $ReqResult = Jaws_HTTPError::Get(403);
    } else {
        $ReqResult = $objAction->Execute($ReqAction);
        if (Jaws_Error::IsError($ReqResult)) {
            Jaws_Error::Fatal($ReqResult->getMessage());
        }
    }
    $IsReqActionStandAlone = $objAction->IsStandAloneAdmin($ReqAction);
    if (!$IsReqActionStandAlone) {
        // Load ControlPanel header
        $GLOBALS['app']->Layout->LoadControlPanelHead();
        $GLOBALS['app']->Layout->Populate($ReqResult);
        $GLOBALS['app']->Layout->AddHeadLink('gadgets/' . $ReqGadget . '/Resources/style.css?' . $objAction->gadget->version, 'stylesheet', 'text/css');
        $GLOBALS['app']->Layout->LoadControlPanel($ReqGadget);
        $ReqResult = $GLOBALS['app']->Layout->Get();
    }
Ejemplo n.º 28
0
 /**
  * Downloads the theme
  *
  * @access  public
  * @returns void
  */
 function DownloadTheme()
 {
     $theme = jaws()->request->fetch('theme', 'get');
     @(list($theme, $locality) = explode(',', $theme));
     $tInfo = Jaws_Utils::GetThemesInfo($locality, $theme);
     if (!empty($tInfo)) {
         if (!$tInfo['download']) {
             return Jaws_HTTPError::Get(403);
         }
         $tmpDir = sys_get_temp_dir();
         $tmsModel = $this->gadget->model->loadAdmin('Themes');
         $res = $tmsModel->packTheme($tInfo['name'], ($locality == 0 ? JAWS_DATA : JAWS_BASE_DATA) . 'themes', $tmpDir, false);
         if (!Jaws_Error::isError($res)) {
             Jaws_Utils::Download($res, "{$theme}.zip");
             return;
         }
     } else {
         return Jaws_HTTPError::Get(404);
     }
 }
Ejemplo n.º 29
0
 /**
  * Display forums of a group
  *
  * @access  public
  * @return  string  XHTML template content
  */
 function Group($group = null, $tpl = null)
 {
     if (!is_array($group)) {
         $group = jaws()->request->fetch('gid', 'get');
         $gModel = $this->gadget->model->load('Groups');
         $group = $gModel->GetGroup($group);
         if (Jaws_Error::IsError($group) || empty($group) || !$group['published']) {
             return Jaws_HTTPError::Get(404);
         }
     }
     $objDate = Jaws_Date::getInstance();
     if (is_null($tpl)) {
         $block = 'groups';
         $GLOBALS['app']->Layout->SetTitle($group['title']);
         $tpl = $this->gadget->template->load('Group.html');
         $tpl->SetBlock("{$block}");
         $tpl->SetVariable('findex_title', _t('FORUMS_FORUMS'));
         $tpl->SetVariable('findex_url', $this->gadget->urlMap('Forums'));
         $tpl->SetVariable('title', $group['title']);
         $tpl->SetVariable('url', $this->gadget->urlMap('Group', array('gid' => $group['id'])));
         $tpl->SetVariable('description', $group['description']);
         $standalone = true;
     } else {
         $standalone = false;
         $block = 'forums';
     }
     // date format
     $date_format = $this->gadget->registry->fetch('date_format');
     $date_format = empty($date_format) ? 'DN d MN Y' : $date_format;
     // posts per page
     $posts_limit = $this->gadget->registry->fetch('posts_limit');
     $posts_limit = empty($posts_limit) ? 10 : (int) $posts_limit;
     $fModel = $this->gadget->model->load('Forums');
     $forums = $fModel->GetForums($group['id'], true, true, true);
     if (Jaws_Error::IsError($forums)) {
         return false;
     }
     $tpl->SetBlock("{$block}/group");
     $tpl->SetVariable('title', $group['title']);
     $tpl->SetVariable('url', $this->gadget->urlMap('Group', array('gid' => $group['id'])));
     $tpl->SetVariable('lbl_topics', _t('FORUMS_TOPICS'));
     $tpl->SetVariable('lbl_posts', _t('FORUMS_POSTS'));
     $tpl->SetVariable('lbl_lastpost', _t('FORUMS_LASTPOST'));
     foreach ($forums as $forum) {
         $tpl->SetBlock("{$block}/group/forum");
         $tpl->SetVariable('status', (int) $forum['locked']);
         $tpl->SetVariable('title', $forum['title']);
         $tpl->SetVariable('url', $this->gadget->urlMap('Topics', array('fid' => $forum['id'])));
         $tpl->SetVariable('description', $forum['description']);
         $tpl->SetVariable('topics', (int) $forum['topics']);
         $tpl->SetVariable('posts', (int) $forum['posts']);
         // last post
         if (!empty($forum['last_topic_id'])) {
             $tpl->SetBlock("{$block}/group/forum/lastpost");
             $tpl->SetVariable('postedby_lbl', _t('FORUMS_POSTEDBY'));
             $tpl->SetVariable('username', $forum['username']);
             $tpl->SetVariable('nickname', $forum['nickname']);
             $tpl->SetVariable('user_url', $GLOBALS['app']->Map->GetURLFor('Users', 'Profile', array('user' => $forum['username'])));
             $tpl->SetVariable('lastpost_lbl', _t('FORUMS_LASTPOST'));
             $tpl->SetVariable('lastpost_date', $objDate->Format($forum['last_post_time'], $date_format));
             $tpl->SetVariable('lastpost_date_iso', $objDate->ToISO((int) $forum['last_post_time']));
             $url_params = array('fid' => $forum['id'], 'tid' => $forum['last_topic_id']);
             $last_post_page = floor(($forum['replies'] - 1) / $posts_limit) + 1;
             if ($last_post_page > 1) {
                 $url_params['page'] = $last_post_page;
             }
             $tpl->SetVariable('lastpost_url', $this->gadget->urlMap('Posts', $url_params));
             $tpl->ParseBlock("{$block}/group/forum/lastpost");
         }
         $tpl->ParseBlock("{$block}/group/forum");
     }
     $tpl->ParseBlock("{$block}/group");
     if ($standalone) {
         $tpl->ParseBlock("{$block}");
         return $tpl->Get();
     }
 }
Ejemplo n.º 30
0
 /**
  * Display a message Info
  *
  * @access  public
  * @return  string  XHTML template content
  */
 function Message()
 {
     if (!$GLOBALS['app']->Session->Logged()) {
         return Jaws_HTTPError::Get(401);
     }
     $id = jaws()->request->fetch('id', 'get');
     $date = Jaws_Date::getInstance();
     $model = $this->gadget->model->load('Message');
     $user = $GLOBALS['app']->Session->GetAttribute('user');
     $usrModel = new Jaws_User();
     $message = $model->GetMessage($id, true);
     if (empty($message)) {
         return Jaws_HTTPError::Get(404);
     }
     // Check permissions
     if (!($message['from'] == $user && $message['to'] == 0) && $message['to'] != $user) {
         return Jaws_HTTPError::Get(403);
     }
     // Detect message folder
     if ($message['from'] == $user && $message['to'] != $user) {
         $folder = PrivateMessage_Info::PRIVATEMESSAGE_FOLDER_OUTBOX;
     } else {
         $folder = PrivateMessage_Info::PRIVATEMESSAGE_FOLDER_INBOX;
     }
     if ($folder == PrivateMessage_Info::PRIVATEMESSAGE_FOLDER_INBOX && $message['read'] == false) {
         $user = $GLOBALS['app']->Session->GetAttribute('user');
         $model->MarkMessages($id, true, $user);
     }
     $date_format = $this->gadget->registry->fetch('date_format');
     $tpl = $this->gadget->template->load('Message.html');
     $tpl->SetBlock('message');
     $tpl->SetVariable('id', $id);
     $tpl->SetBlock('message');
     $tpl->SetVariable('confirmTrash', _t('PRIVATEMESSAGE_MESSAGE_CONFIRM_TRASH'));
     $tpl->SetVariable('confirmDelete', _t('PRIVATEMESSAGE_MESSAGE_CONFIRM_DELETE'));
     $tpl->SetVariable('lbl_from', _t('PRIVATEMESSAGE_MESSAGE_FROM'));
     $tpl->SetVariable('lbl_send_time', _t('PRIVATEMESSAGE_MESSAGE_SEND_TIME'));
     $tpl->SetVariable('lbl_subject', _t('PRIVATEMESSAGE_MESSAGE_SUBJECT'));
     $tpl->SetVariable('lbl_body', _t('PRIVATEMESSAGE_MESSAGE_BODY'));
     $tpl->SetVariable('from', $message['from_nickname']);
     $tpl->SetVariable('username', $message['from_username']);
     $tpl->SetVariable('nickname', $message['from_nickname']);
     $tpl->SetVariable('send_time', $date->Format($message['insert_time'], $date_format));
     $tpl->SetVariable('subject', $message['subject']);
     $tpl->SetVariable('body', $this->gadget->ParseText($message['body'], 'PrivateMessage', 'index'));
     $tpl->SetVariable('trash_url', $this->gadget->urlMap('TrashMessage', array('id' => $id)));
     $tpl->SetVariable('delete_url', $this->gadget->urlMap('DeleteMessage', array('id' => $id)));
     // user's avatar
     $tpl->SetVariable('avatar', $usrModel->GetAvatar($message['avatar'], $message['email'], 80));
     // user's profile
     $tpl->SetVariable('user_url', $GLOBALS['app']->Map->GetURLFor('Users', 'Profile', array('user' => $message['from_username'])));
     if (!empty($message['attachments'])) {
         $tpl->SetBlock('message/attachment');
         $tpl->SetVariable('lbl_attachments', _t('PRIVATEMESSAGE_MESSAGE_ATTACHMENTS'));
         foreach ($message['attachments'] as $file) {
             $tpl->SetBlock('message/attachment/file');
             $tpl->SetVariable('lbl_file_size', _t('PRIVATEMESSAGE_MESSAGE_FILE_SIZE'));
             $tpl->SetVariable('file_name', $file['title']);
             $tpl->SetVariable('file_size', Jaws_Utils::FormatSize($file['filesize']));
             $tpl->SetVariable('file_download_link', $file['title']);
             $file_url = $this->gadget->urlMap('Attachment', array('uid' => $user, 'mid' => $message['id'], 'aid' => $file['id']));
             $tpl->SetVariable('file_download_link', $file_url);
             $tpl->ParseBlock('message/attachment/file');
         }
         $tpl->ParseBlock('message/attachment');
     }
     if ($message['folder'] != PrivateMessage_Info::PRIVATEMESSAGE_FOLDER_TRASH) {
         $tpl->SetBlock('message/archive');
         if ($message['folder'] == PrivateMessage_Info::PRIVATEMESSAGE_FOLDER_ARCHIVED) {
             $tpl->SetVariable('icon_archive', 'gadgets/PrivateMessage/Resources/images/unarchive-mini.png');
             $tpl->SetVariable('archive', _t('PRIVATEMESSAGE_UNARCHIVE'));
             $tpl->SetVariable('archive_url', $this->gadget->urlMap('UnArchiveMessage', array('id' => $id)));
         } else {
             $tpl->SetVariable('icon_archive', 'gadgets/PrivateMessage/Resources/images/archive-mini.png');
             $tpl->SetVariable('archive', _t('PRIVATEMESSAGE_ARCHIVE'));
             $tpl->SetVariable('archive_url', $this->gadget->urlMap('ArchiveMessage', array('id' => $id)));
         }
         $tpl->ParseBlock('message/archive');
     }
     if ($message['folder'] != PrivateMessage_Info::PRIVATEMESSAGE_FOLDER_DRAFT && $message['folder'] != PrivateMessage_Info::PRIVATEMESSAGE_FOLDER_TRASH) {
         if ($folder == PrivateMessage_Info::PRIVATEMESSAGE_FOLDER_INBOX) {
             $tpl->SetBlock('message/reply');
             $tpl->SetVariable('reply_url', $this->gadget->urlMap('Compose', array('id' => $message['id'], 'reply' => 'true')));
             $tpl->SetVariable('icon_reply', 'gadgets/PrivateMessage/Resources/images/reply-mini.png');
             $tpl->SetVariable('reply', _t('PRIVATEMESSAGE_REPLY'));
             $tpl->ParseBlock('message/reply');
         }
         $tpl->SetBlock('message/forward');
         $tpl->SetVariable('forward_url', $this->gadget->urlMap('Compose', array('id' => $message['id'], 'reply' => 'false')));
         $tpl->SetVariable('icon_forward', 'gadgets/PrivateMessage/Resources/images/forward-mini.png');
         $tpl->SetVariable('forward', _t('PRIVATEMESSAGE_FORWARD'));
         $tpl->ParseBlock('message/forward');
     }
     if ($message['folder'] != PrivateMessage_Info::PRIVATEMESSAGE_FOLDER_TRASH) {
         $tpl->SetBlock('message/trash');
         $tpl->SetVariable('icon_trash', 'gadgets/PrivateMessage/Resources/images/trash-mini.png');
         $tpl->SetVariable('trash', _t('PRIVATEMESSAGE_TRASH'));
         $tpl->ParseBlock('message/trash');
     }
     if ($message['folder'] == PrivateMessage_Info::PRIVATEMESSAGE_FOLDER_TRASH) {
         $tpl->SetBlock('message/restore_trash');
         $tpl->SetVariable('restore_trash_url', $this->gadget->urlMap('RestoreTrashMessage', array('id' => $id)));
         $tpl->SetVariable('icon_restore_trash', '');
         $tpl->SetVariable('restore_trash', _t('PRIVATEMESSAGE_RESTORE_TRASH'));
         $tpl->ParseBlock('message/restore_trash');
         $tpl->SetBlock('message/delete');
         $tpl->SetVariable('icon_delete', STOCK_DELETE);
         $tpl->SetVariable('delete', _t('GLOBAL_DELETE'));
         $tpl->ParseBlock('message/delete');
     }
     $tpl->SetBlock('message/back');
     $tpl->SetVariable('back_url', $this->gadget->urlMap('Messages'));
     $tpl->SetVariable('icon_back', 'gadgets/PrivateMessage/Resources/images/back-mini.png');
     $tpl->SetVariable('back', _t('PRIVATEMESSAGE_BACK'));
     $tpl->ParseBlock('message/back');
     $tpl->ParseBlock('message');
     return $tpl->Get();
 }