/** * Displays blog comments manager * * @access public * @return string XHTML template content */ function ManageComments() { $this->gadget->CheckPermission('ManageComments'); if (!Jaws_Gadget::IsGadgetInstalled('Comments')) { Jaws_Header::Location(BASE_SCRIPT . '?gadget=Blog'); } $cHTML = Jaws_Gadget::getInstance('Comments')->action->loadAdmin('Comments'); return $cHTML->Comments($this->gadget->name, $this->MenuBar('ManageComments')); }
/** * 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(''); }
/** * Event execute method * */ function Execute($shouter, $code) { $reqURL = Jaws_Utils::getRequestURL(true); $uModel = $this->gadget->model->loadAdmin('ErrorMaps'); $res = $uModel->GetHTTPError($reqURL, $code); if (!Jaws_Error::IsError($res) && !empty($res) && ($res['code'] == 301 || $res['code'] == 302)) { Jaws_Header::Location($res['url'], $res['code']); } return $res; }
/** * 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(''); }
/** * 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; }
/** * Redirect to the URL and increase the clicks by one * * @access public */ function Link() { $lid = jaws()->request->fetch('id', 'get'); $lid = Jaws_XSS::defilter($lid); $model = $this->gadget->model->load('Links'); $link = $model->GetLink($lid); if (!Jaws_Error::IsError($link) && !empty($link)) { $click = $model->Click($link['id']); if (!Jaws_Error::IsError($click)) { Jaws_Header::Location($link['url'], null, 301); } } // By default, on the errors stay in the main page Jaws_Header::Referrer(); }
/** * Creates a new note * * @access public * @return array Response array */ function CreateNote() { $data = jaws()->request->fetch(array('title', 'content'), 'post'); if (empty($data['title']) || empty($data['content'])) { $GLOBALS['app']->Session->PushResponse(_t('NOTEPAD_ERROR_INCOMPLETE_DATA'), 'Notepad.Response', RESPONSE_ERROR, $data); Jaws_Header::Referrer(); } $model = $this->gadget->model->load('Notepad'); $data['user'] = (int) $GLOBALS['app']->Session->GetAttribute('user'); $data['title'] = Jaws_XSS::defilter($data['title']); $data['content'] = Jaws_XSS::defilter($data['content']); $result = $model->Insert($data); if (Jaws_Error::IsError($result)) { $GLOBALS['app']->Session->PushResponse(_t('NOTEPAD_ERROR_NOTE_CREATE'), 'Notepad.Response', RESPONSE_ERROR, $data); Jaws_Header::Referrer(); } $GLOBALS['app']->Session->PushResponse(_t('NOTEPAD_NOTICE_NOTE_CREATED'), 'Notepad.Response'); Jaws_Header::Location($this->gadget->urlMap('Notepad')); }
/** * Saves a new trackback if all is ok and sends response * The function other people send to so our blog gadget * gets trackbacks * * @access public * @return string trackback xml response */ function Trackback() { // Based on Wordpress trackback implementation $tb_msg_error = '<?xml version="1.0" encoding="iso-8859-1"?><response><error>1</error><message>#MESSAGE#</message></response>'; $tb_msg_ok = '<?xml version="1.0" encoding="iso-8859-1"?><response><error>0</error></response>'; $sender = Jaws_Utils::GetRemoteAddress(); $ip = $sender['proxy'] . (!empty($sender['proxy']) ? '-' : '') . $sender['client']; $post = jaws()->request->fetch(array('title', 'url', 'blog_name', 'excerpt'), 'post'); if (is_null($post['title']) || is_null($post['url']) || is_null($post['blog_name']) || is_null($post['excerpt'])) { Jaws_Header::Location(''); } $id = jaws()->request->fetch('id', 'get'); if (is_null($id)) { $id = jaws()->request->fetch('id', 'post'); if (is_null($id)) { $id = ''; } } $title = urldecode($post['title']); $url = urldecode($post['url']); $blogname = urldecode($post['blog_name']); $excerpt = urldecode($post['excerpt']); if (trim($id) == '') { Jaws_Header::Location(''); } elseif (empty($title) && empty($url) && empty($blogname)) { $url = $this->gadget->urlMap('SingleView', array('id' => $id), true); Jaws_Header::Location($url); } elseif ($this->gadget->registry->fetch('trackback') == 'true') { header('Content-Type: text/xml'); $model = $this->gadget->model->load('Trackbacks'); $trackback = $model->NewTrackback($id, $url, $title, $excerpt, $blogname, $ip); if (Jaws_Error::IsError($trackback)) { return str_replace('#MESSAGE#', $trackback->GetMessage(), $tb_msg_error); } return $tb_msg_ok; } else { header('Content-Type: text/xml'); return str_replace('#MESSAGE#', _t('BLOG_TRACKBACK_DISABLED'), $tb_msg_error); } }
/** * 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')); }
/** * Searches through notes including shared noes from other users * * @access public * @return array Response array */ function Search() { $post = jaws()->request->fetch(array('filter', 'query', 'page'), 'post'); foreach ($post as $k => $v) { if ($v === null) { unset($post[$k]); } } $url = $this->gadget->urlMap('Notepad', $post); Jaws_Header::Location($url); /*if (strlen($search['query']) < 2) { $GLOBALS['app']->Session->PushResponse( _t('NOTEPAD_ERROR_SHORT_QUERY'), 'Notepad.Response', RESPONSE_ERROR ); }*/ }
/** * 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); } }
/** * Update a user's group * * @access public * @return void */ function UpdateGroup() { $this->gadget->CheckPermission('ManageUserGroups'); $post = jaws()->request->fetch(array('gid', 'name', 'title', 'description', 'enabled'), 'post'); $selected_members = jaws()->request->fetch('members:array', 'post'); $user = $GLOBALS['app']->Session->GetAttribute('user'); $post['enabled'] = (bool) $post['enabled']; $jUser = new Jaws_User(); $res = $jUser->UpdateGroup($post['gid'], $post, $user); $current_members_info = $jUser->GetUsers($post['gid']); $current_members = array(); foreach ($current_members_info as $member_info) { $current_members[] = $member_info['id']; } $new_member = array_diff($selected_members, $current_members); if (!Jaws_Error::isError($res) && count($new_member) > 0) { // TODO: improve performance foreach ($new_member as $member) { $res = $jUser->AddUserToGroup($member, $post['gid'], $user); } } $removed_member = array_diff($current_members, $selected_members); if (!Jaws_Error::isError($res) && count($removed_member) > 0) { // TODO: improve performance foreach ($removed_member as $member) { $res = $jUser->DeleteUserFromGroup($member, $post['gid'], $user); } } if (Jaws_Error::isError($res)) { $GLOBALS['app']->Session->PushResponse($res->getMessage(), 'Users.Groups', RESPONSE_ERROR); } elseif ($res == true) { $GLOBALS['app']->Session->PushResponse(_t('USERS_GROUPS_UPDATED', $post['title']), 'Users.Groups', RESPONSE_NOTICE); } Jaws_Header::Location($this->gadget->urlMap('Groups')); }
/** * Redirect to layout manager * * @access public * @return void */ function Layout() { Jaws_Header::Location($this->gadget->urlMap('Layout', array())); }
/** * Searches among events * * @access public * @return array Response array */ function Search() { $post = jaws()->request->fetch(array('query', 'filter', 'start', 'stop', 'page'), 'post'); $GLOBALS['app']->Session->PushSimpleResponse($post, 'Events.Search'); $url = $this->gadget->urlMap('ManageEvents'); Jaws_Header::Location($url); }
/** * Updates note * * @access public * @return array Response array */ function UpdateNote() { $data = jaws()->request->fetch(array('id', 'title', 'content'), 'post'); if (empty($data['id']) || empty($data['title']) || empty($data['content'])) { $GLOBALS['app']->Session->PushResponse(_t('NOTEPAD_ERROR_INCOMPLETE_DATA'), 'Notepad.Response', RESPONSE_ERROR, $data); Jaws_Header::Referrer(); } // Validate note $model = $this->gadget->model->load('Notepad'); $id = (int) $data['id']; $user = (int) $GLOBALS['app']->Session->GetAttribute('user'); $note = $model->GetNote($id, $user); if (Jaws_Error::IsError($note)) { $GLOBALS['app']->Session->PushResponse(_t('NOTEPAD_ERROR_RETRIEVING_DATA'), 'Notepad.Response', RESPONSE_ERROR); Jaws_Header::Referrer(); } // Verify owner if ($note['user'] != $user) { $GLOBALS['app']->Session->PushResponse(_t('NOTEPAD_ERROR_NO_PERMISSION'), 'Notepad.Response', RESPONSE_ERROR); Jaws_Header::Referrer(); } $data['title'] = Jaws_XSS::defilter($data['title']); $data['content'] = Jaws_XSS::defilter($data['content']); $result = $model->Update($id, $data); if (Jaws_Error::IsError($result)) { $GLOBALS['app']->Session->PushResponse(_t('NOTEPAD_ERROR_NOTE_UPDATE'), 'Notepad.Response', RESPONSE_ERROR, $data); Jaws_Header::Referrer(); } $GLOBALS['app']->Session->PushResponse(_t('NOTEPAD_NOTICE_NOTE_UPDATED'), 'Notepad.Response'); Jaws_Header::Location($this->gadget->urlMap('Notepad')); }
/** * 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'); }
/** * Updates user contacts information * * @access public * @return void */ function UpdateContacts() { if (!$GLOBALS['app']->Session->Logged()) { Jaws_Header::Location($this->gadget->urlMap('LoginBox', array('referrer' => bin2hex(Jaws_Utils::getRequestURL(true))))); } $this->gadget->CheckPermission('EditUserContacts'); $post = jaws()->request->fetch(array('country', 'city', 'address', 'postal_code', 'phone_number', 'mobile_number', 'fax_number'), 'post'); $uModel = $this->gadget->model->load('Contacts'); $result = $uModel->UpdateContacts($GLOBALS['app']->Session->GetAttribute('user'), $post['country'], $post['city'], $post['address'], $post['postal_code'], $post['phone_number'], $post['mobile_number'], $post['fax_number']); if (Jaws_Error::IsError($result)) { $GLOBALS['app']->Session->PushResponse($result->GetMessage(), 'Users.Contacts', RESPONSE_ERROR, $post); } else { $GLOBALS['app']->Session->PushResponse(_t('USERS_USERS_CONTACTINFO_UPDATED'), 'Users.Contacts'); } Jaws_Header::Location($this->gadget->urlMap('Contacts'), 'Users.Contacts'); }
/** * Delete a file in text editor mode * * @access public * @return void */ function DeleteFile() { $this->gadget->CheckPermission('ManageFiles'); $model = $this->gadget->model->loadAdmin('Files'); $post = jaws()->request->fetch(array('path', 'selected_item', 'extra_params'), 'post'); if ($model->Delete($post['path'], $post['selected_item'])) { $model->DeleteDBFileInfo($post['path'], $post['selected_item']); } Jaws_Header::Location(BASE_SCRIPT . '?gadget=FileBrowser&action=BrowseFile&path=' . $post['path'] . html_entity_decode($post['extra_params'])); }
/** * Delete message permanently * * @access public * @return void */ function DeleteMessage() { $this->gadget->CheckPermission('DeleteMessage'); $ids = jaws()->request->fetch('id', 'get'); $messagesSelected = jaws()->request->fetch('message_checkbox:array', 'post'); if (!empty($messagesSelected) && count($messagesSelected) > 0) { $ids = $messagesSelected; } $model = $this->gadget->model->load('Message'); $user = $GLOBALS['app']->Session->GetAttribute('user'); $res = $model->DeleteMessage($ids, $user); if (Jaws_Error::IsError($res)) { $GLOBALS['app']->Session->PushResponse($res->getMessage(), 'PrivateMessage.Message', RESPONSE_ERROR); } if ($res == true) { $GLOBALS['app']->Session->PushResponse(_t('PRIVATEMESSAGE_MESSAGE_DELETED'), 'PrivateMessage.Message', RESPONSE_NOTICE); } else { $GLOBALS['app']->Session->PushResponse(_t('PRIVATEMESSAGE_MESSAGE_NOT_DELETED'), 'PrivateMessage.Message', RESPONSE_ERROR); } if (count($messagesSelected) > 0) { Jaws_Header::Referrer(); } else { Jaws_Header::Location($this->gadget->urlMap('Messages', array('folder' => PrivateMessage_Info::PRIVATEMESSAGE_FOLDER_INBOX))); } }
define('COMPRESS_LEVEL', 4); } // Lets support older PHP versions so we can use spanking new functions require JAWS_PATH . 'include/Jaws/PHPFunctions.php'; // lets setup the include_path set_include_path('.' . PATH_SEPARATOR . JAWS_PATH . 'libraries/pear'); // Create application $GLOBALS['app'] = jaws(); // get an instance of Jaws_DB $objDatabase = Jaws_DB::getInstance('default', $db); if (Jaws_Error::IsError($objDatabase)) { Jaws_Error::Fatal($objDatabase->getMessage()); } $db_jaws_version = $GLOBALS['app']->Registry->Init(); if ($db_jaws_version != JAWS_VERSION) { if (strrstr(JAWS_VERSION, '.', true) != strrstr($db_jaws_version, '.', true)) { //require_once JAWS_PATH . 'upgrade/JawsUpgrader.php'; //require_once JAWS_PATH . 'upgrade/JawsUpgraderStage.php'; //require_once JAWS_PATH . 'upgrade/stages/111To120.php'; //$objStage = new Upgrader_111To120; //$result = $objStage->Run(); //if (Jaws_Error::IsError($result)) { Jaws_Header::Location('upgrade/index.php'); //} } $GLOBALS['app']->Registry->update('version', JAWS_VERSION); } // init application $GLOBALS['app']->init(); // load Piwi initialize require_once JAWS_PATH . 'include/Jaws/InitPiwi.php';
} else { $loginMsg = $resCheck->GetMessage(); } } if ($httpAuthEnabled) { $httpAuth->showLoginBox(); } // Init layout $GLOBALS['app']->InstanceLayout(); $cpl = Jaws_Gadget::getInstance('ControlPanel')->action->loadAdmin('Login'); $data = $cpl->LoginBox($loginMsg); terminate($data, 401); } // remove checksess(check session) parameter from requested url if (!is_null(jaws()->request->fetch('checksess', 'get'))) { Jaws_Header::Location(substr(Jaws_Utils::getRequestURL(false), 0, -10)); } // Can use Control Panel? $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();
/** * Uploads a new theme * * @access public * @return void */ function UploadTheme() { $this->gadget->CheckPermission('UploadTheme'); $res = Jaws_Utils::ExtractFiles($_FILES, JAWS_DATA . 'themes' . DIRECTORY_SEPARATOR, false); if (!Jaws_Error::IsError($res)) { $GLOBALS['app']->Session->PushLastResponse(_t('TMS_THEME_UPLOADED'), RESPONSE_NOTICE); } else { $GLOBALS['app']->Session->PushLastResponse($res->getMessage(), RESPONSE_ERROR); } Jaws_Header::Location(BASE_SCRIPT . '?gadget=Tms&action=Themes'); }
/** * Adds a new emblem * * @access public * @see EmblemsModel->AddEmblem() */ function AddEmblem() { $post = jaws()->request->fetch(array('title', 'url', 'type', 'published'), 'post'); $post['url'] = Jaws_XSS::defilter($post['url']); $res = Jaws_Utils::UploadFiles($_FILES, JAWS_DATA . 'emblems/', 'jpg,gif,swf,png,jpeg,bmp,svg'); if (Jaws_Error::IsError($res)) { $GLOBALS['app']->Session->PushLastResponse($res->getMessage(), RESPONSE_ERROR); } elseif (empty($res)) { $GLOBALS['app']->Session->PushLastResponse(_t('EMBLEMS_ERROR_NO_IMAGE_UPLOADED'), RESPONSE_ERROR); } else { $post['image'] = $res['image'][0]['host_filename']; $post['published'] = (bool) $post['published']; $model = $this->gadget->model->loadAdmin('Emblems'); $res = $model->AddEmblem($post); if (Jaws_Error::IsError($res)) { Jaws_Utils::delete(JAWS_DATA . 'emblems/' . $post['image']); $GLOBALS['app']->Session->PushLastResponse(_t('EMBLEMS_ERROR_NOT_ADDED'), RESPONSE_ERROR); } else { $GLOBALS['app']->Session->PushLastResponse(_t('EMBLEMS_ADDED'), RESPONSE_NOTICE); } } Jaws_Header::Location(BASE_SCRIPT . '?gadget=Emblems'); }
/** * Shows confirm. screen for deleting a blog entry or deletes it if confirm. was done * * @access public * @return string XHTML template content */ function DeleteEntry() { $this->gadget->CheckPermission('DeleteEntries'); $model = $this->gadget->model->loadAdmin('Posts'); $bModel = $this->gadget->model->load('Posts'); $post = jaws()->request->fetch(array('id', 'step'), 'post'); if (!is_null($post['step']) && $post['step'] == 'delete') { // Delete Post $res = $model->DeleteEntry($post['id']); if (Jaws_Error::IsError($res)) { $GLOBALS['app']->Session->PushLastResponse(_t('BLOG_ERROR_ENTRY_NOT_DELETED'), RESPONSE_ERROR); } else { $GLOBALS['app']->Session->PushLastResponse(_t('BLOG_ENTRY_DELETED'), RESPONSE_NOTICE); } Jaws_Header::Location(BASE_SCRIPT . '?gadget=Blog&action=ListEntries'); } $get = jaws()->request->fetch(array('id', 'action'), 'get'); // Ask for confirmation... $entry = $bModel->GetEntry($get['id']); if (Jaws_Error::IsError($entry)) { $GLOBALS['app']->Session->PushLastResponse(_t('BLOG_ERROR_DOES_NOT_EXISTS')); Jaws_Header::Location(BASE_SCRIPT . '?gadget=Blog&action=ListEntries'); } $tpl = $this->gadget->template->loadAdmin('EntryDelete.html'); $tpl->SetBlock('delete_entry'); $tpl->SetVariable('base_script', BASE_SCRIPT); // Header $tpl->SetVariable('menubar', $this->MenuBar($get['action'])); // Message $tpl->SetVariable('delete_message', _t('BLOG_DELETE_CONFIRM_ENTRY')); // Delete $deleteButton =& Piwi::CreateWidget('Button', 'delete', _t('GLOBAL_DELETE'), STOCK_DELETE); $deleteButton->SetSubmit(); $tpl->SetVariable('delete_button', $deleteButton->Get()); // Cancel $cancelButton =& Piwi::CreateWidget('Button', 'cancel', _t('GLOBAL_CANCEL'), STOCK_CANCEL); $cancelButton->AddEvent(ON_CLICK, "javascript: this.form.action.value = 'ListEntries'; this.form.submit(); "); $tpl->SetVariable('cancel_button', $cancelButton->Get()); // ID $idHidden =& Piwi::CreateWidget('HiddenEntry', 'id', $get['id']); $tpl->SetVariable('id', $idHidden->Get()); $tpl->SetVariable('title', $entry['title']); $tpl->SetVariable('text', $this->gadget->ParseText($entry['text'])); $tpl->SetVariable('user', $entry['username']); $date = Jaws_Date::getInstance(); $tpl->SetVariable('createtime', $date->Format($entry['publishtime'])); $pos = 1; $categories = ''; foreach ($entry['categories'] as $cat) { $categories .= $cat['name']; if ($pos != count($entry['categories'])) { $categories .= ', '; } $pos++; } $tpl->SetVariable('category', $categories); $tpl->ParseBlock('delete_entry'); return $tpl->Get(); }
/** * Deletes the given blog category * * @access public */ function DeleteCategory() { $this->gadget->CheckPermission('ManageCategories'); $model = $this->gadget->model->loadAdmin('Categories'); $model->DeleteCategory(jaws()->request->fetch('catid', 'post')); Jaws_Header::Location(BASE_SCRIPT . '?gadget=Blog&action=ManageCategories'); }
/** * Delete a photo * * @access public */ function DeletePhoto() { $post = jaws()->request->fetch(array('image', 'fromalbum'), 'post'); $model = $this->gadget->model->loadAdmin('Photos'); $model->DeletePhoto($post['image']); Jaws_Header::Location(BASE_SCRIPT . '?gadget=Phoo&album=' . $post['fromalbum']); }
/** * 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'); }
/** * Updates the page * * @access public * @return void */ function SaveEditPage() { $this->gadget->CheckPermission('EditPage'); $model = $this->gadget->model->loadAdmin('Page'); $fetch = array('page', 'title', 'group_id', 'language', 'fast_url', 'meta_keys', 'meta_desc', 'tags', 'published', 'show_title'); $post = jaws()->request->fetch($fetch, 'post'); $post['content'] = jaws()->request->fetch('content', 'post', 'strip_crlf'); $id = (int) $post['page']; $model->UpdatePage($id, $post['group_id'], $post['show_title'], $post['title'], $post['content'], $post['language'], $post['fast_url'], $post['meta_keys'], $post['meta_desc'], $post['tags'], $post['published']); Jaws_Header::Location(BASE_SCRIPT . '?gadget=StaticPage&action=EditPage&id=' . $id); }
/** * Updates event * * @access public * @return array Response array */ function UpdateEvent() { $data = jaws()->request->fetch(array('id', 'subject', 'location', 'description', 'type', 'priority', 'reminder', 'recurrence', 'month', 'day', 'wday', 'start_date', 'stop_date', 'start_time', 'stop_time'), 'post'); if (empty($data['subject']) || empty($data['start_date'])) { $GLOBALS['app']->Session->PushResponse(_t('EVENTSCALENDAR_ERROR_INCOMPLETE_DATA'), 'Events.Response', RESPONSE_ERROR, $data); Jaws_Header::Referrer(); } // Validate event $model = $this->gadget->model->load('Event'); $id = (int) $data['id']; $user = (int) $GLOBALS['app']->Session->GetAttribute('user'); $event = $model->GetEvent($id, $user); if (Jaws_Error::IsError($event)) { $GLOBALS['app']->Session->PushResponse(_t('EVENTSCALENDAR_ERROR_RETRIEVING_DATA'), 'Events.Response', RESPONSE_ERROR); Jaws_Header::Referrer(); } // Verify owner if ($event['owner'] != $user) { $GLOBALS['app']->Session->PushResponse(_t('EVENTSCALENDAR_ERROR_NO_PERMISSION'), 'Events.Response', RESPONSE_ERROR); Jaws_Header::Referrer(); } $data['user'] = (int) $GLOBALS['app']->Session->GetAttribute('user'); if (empty($data['stop_date'])) { $data['stop_date'] = $data['start_date']; } if (empty($data['stop_time'])) { $data['stop_time'] = $data['start_time']; } $result = $model->UpdateEvent($id, $data, $event); if (Jaws_Error::IsError($result)) { $GLOBALS['app']->Session->PushResponse(_t('EVENTSCALENDAR_ERROR_EVENT_UPDATE'), 'Events.Response', RESPONSE_ERROR, $data); Jaws_Header::Referrer(); } $GLOBALS['app']->Session->PushResponse(_t('EVENTSCALENDAR_NOTICE_EVENT_UPDATED'), 'Events.Response'); Jaws_Header::Location($this->gadget->urlMap('ManageEvents')); }
/** * Adds a new entry to the comments, sets cookie with user data and redirects to main page * * @access public * @return void */ function PostMessage() { $post = jaws()->request->fetch(array('message', 'name', 'email', 'url', 'url2', 'requested_gadget', 'requested_action', 'reference', 'is_private'), 'post'); if ($GLOBALS['app']->Session->Logged()) { $post['name'] = $GLOBALS['app']->Session->GetAttribute('nickname'); $post['email'] = $GLOBALS['app']->Session->GetAttribute('email'); $post['url'] = $GLOBALS['app']->Session->GetAttribute('url'); } if (trim($post['message']) == '' || trim($post['name']) == '') { $GLOBALS['app']->Session->PushResponse(_t('COMMENTS_COMMENT_INCOMPLETE_FIELDS'), 'Comments', RESPONSE_ERROR, $post); Jaws_Header::Referrer(); } /* lets check if it's spam * it's rather common that spam engines * fill out all inputs and this one is hidden * via CSS so not many engines are smart enough * to not fill this out */ if (!empty($post['url2'])) { $GLOBALS['app']->Session->PushResponse(_t('COMMENTS_FAILED_SPAM_CHECK_MESSAGES'), 'Comments', RESPONSE_ERROR, $post); Jaws_Header::Referrer(); } $mPolicy = Jaws_Gadget::getInstance('Policy')->action->load('Captcha'); $resCheck = $mPolicy->checkCaptcha(); if (Jaws_Error::IsError($resCheck)) { $GLOBALS['app']->Session->PushResponse($resCheck->getMessage(), 'Comments', RESPONSE_ERROR, $post); Jaws_Header::Referrer(); } $permalink = $GLOBALS['app']->GetSiteURL(); $status = $this->gadget->registry->fetch('default_comment_status'); if ($this->gadget->GetPermission('ManageComments')) { $status = Comments_Info::COMMENTS_STATUS_APPROVED; } $objHook = Jaws_Gadget::getInstance($post['requested_gadget'])->hook->load('Comments'); if (Jaws_Error::IsError($objHook)) { $GLOBALS['app']->Session->PushResponse($objHook->getMessage(), 'Comments', RESPONSE_ERROR, $post); Jaws_Header::Referrer(); } $reference = $objHook->Execute($post['requested_action'], $post['reference']); if (empty($reference)) { $GLOBALS['app']->Session->PushResponse(_t('COMMENTS_ERROR_REFERENCE_EXISTS'), 'Comments', RESPONSE_ERROR, $post); Jaws_Header::Referrer(); } $res = $this->gadget->model->load('EditComments')->insertComment($post['requested_gadget'], $post['reference'], $post['requested_action'], $post['name'], $post['email'], $post['url'], $post['message'], $_SERVER['REMOTE_ADDR'], $permalink, $status, $post['is_private']); if (Jaws_Error::isError($res)) { $GLOBALS['app']->Session->PushResponse($res->getMessage(), 'Comments', RESPONSE_ERROR, $post); } else { $this->EmailComment($reference, $post['message']); $GLOBALS['app']->Session->PushResponse(_t('COMMENTS_MESSAGE_SENT'), 'Comments'); } Jaws_Header::Location($reference['url']); }