Example #1
0
 public function connect_forum()
 {
     $config = OW::getConfig();
     $language = OW::getLanguage();
     if ($_GET['isForumConnected'] === 'yes' && !OW::getConfig()->getValue('groups', 'is_forum_connected')) {
         try {
             OW::getAuthorization()->addAction('groups', 'add_topic');
         } catch (Exception $e) {
         }
         // Add forum section
         $event = new OW_Event('forum.create_section', array('name' => 'Groups', 'entity' => 'groups', 'isHidden' => true));
         OW::getEventManager()->trigger($event);
         // Add widget
         $event = new OW_Event('forum.add_widget', array('place' => 'group', 'section' => BOL_ComponentAdminService::SECTION_RIGHT));
         OW::getEventManager()->trigger($event);
         $groupsService = GROUPS_BOL_Service::getInstance();
         $groupList = $groupsService->findGroupList(GROUPS_BOL_Service::LIST_ALL);
         if (!empty($groupList)) {
             foreach ($groupList as $group) {
                 // Add forum group
                 $event = new OW_Event('forum.create_group', array('entity' => 'groups', 'name' => $group->title, 'description' => $group->description, 'entityId' => $group->getId()));
                 OW::getEventManager()->trigger($event);
             }
         }
         $config->saveConfig('groups', 'is_forum_connected', 1);
         OW::getFeedback()->info($language->text('groups', 'forum_connected'));
     }
     $redirectURL = OW::getRouter()->urlForRoute('groups-admin-widget-panel');
     $this->redirect($redirectURL);
 }
Example #2
0
 public function onCollectProfileActions(BASE_CLASS_EventCollector $event)
 {
     if (!OW::getUser()->isAuthenticated()) {
         return;
     }
     $params = $event->getParams();
     $targetUserID = $params['userId'];
     if (empty($targetUserID) || $targetUserID == OW::getUser()->getId() || !OW::getAuthorization()->isUserAuthorized($targetUserID, 'credits', 'receive')) {
         return;
     }
     $linkId = 'credits' . rand(10, 1000000);
     $event->add(array("label" => OW::getLanguage()->text('credits', 'profile_label_send'), "href" => OW::getRouter()->urlFor('CREDITS_MCTRL_Action', 'send', array('id' => $targetUserID)), "id" => $linkId));
 }
Example #3
0
function credits_members_action_tool(BASE_CLASS_EventCollector $event)
{
    if (!OW::getUser()->isAuthenticated()) {
        return;
    }
    $params = $event->getParams();
    $targetUserID = $params['userId'];
    if (empty($targetUserID) || $targetUserID == OW::getUser()->getId() || !OW::getAuthorization()->isUserAuthorized($targetUserID, 'credits', 'receive')) {
        return;
    }
    $user = BOL_UserService::getInstance()->getUserName((int) $targetUserID);
    $linkId = 'credits' . rand(10, 1000000);
    $resultArray = array(BASE_CMP_ProfileActionToolbar::DATA_KEY_LABEL => OW::getLanguage()->text('credits', 'profile_label_send'), BASE_CMP_ProfileActionToolbar::DATA_KEY_LINK_HREF => OW::getRouter()->urlFor('CREDITS_CTRL_Action', 'send', array('id' => $targetUserID)), BASE_CMP_ProfileActionToolbar::DATA_KEY_LINK_ID => $linkId);
    $event->add($resultArray);
}
Example #4
0
 /**
  * @return Constructor.
  */
 public function __construct($paramObj)
 {
     parent::__construct();
     // check if comments are empty and user can't add comments
     if ((int) BOL_CommentService::getInstance()->findCommentCount('base_index_wall', 1) === 0) {
         if (!OW::getUser()->isAuthenticated() || !OW::getAuthorization()->isUserAuthorized(OW::getUser()->getId(), 'base', 'add_comment')) {
             $this->setVisible(false);
         }
     }
     $params = $paramObj->customParamList;
     $commentParams = new BASE_CommentsParams('base', 'base_index_wall');
     if (isset($params['comments_count'])) {
         $commentParams->setCommentCountOnPage($params['comments_count']);
     }
     $commentParams->setDisplayType(BASE_CommentsParams::DISPLAY_TYPE_TOP_FORM_WITH_PAGING);
     $commentParams->setWrapInBox(false);
     $this->addComponent('comments', new BASE_CMP_Comments($commentParams));
 }
Example #5
0
 /**
  * Default action
  */
 public function index()
 {
     $lang = OW::getLanguage();
     $form = new OCSFAVORITES_CLASS_SettingsForm();
     $this->addForm($form);
     if (OW::getRequest()->isPost() && $form->isValid($_POST)) {
         $values = $form->getValues();
         $canView = (int) $values['canView'];
         OW::getConfig()->saveConfig('ocsfavorites', 'can_view', $canView);
         $authorization = OW::getAuthorization();
         $groupName = 'ocsfavorites';
         if ($canView) {
             $authorization->addAction($groupName, 'view_users', false);
         } else {
             $authorization->deleteAction($groupName, 'view_users');
         }
         OW::getFeedback()->info($lang->text('ocsfavorites', 'settings_updated'));
         $this->redirect();
     }
     $form->getElement('canView')->setValue(OW::getConfig()->getValue('ocsfavorites', 'can_view'));
     $logo = OW::getPluginManager()->getPlugin('ocsfavorites')->getStaticUrl() . 'img/oxwallcandystore-logo.jpg';
     $this->assign('logo', $logo);
     $this->setPageHeading($lang->text('ocsfavorites', 'page_heading_admin'));
 }
Example #6
0
 public function send(array $params = null)
 {
     if (!OW::getUser()->isAuthenticated()) {
         throw new AuthenticateException();
     }
     $receiveUser = $params['id'];
     if (!OW::getUser()->isAuthorized('credits', 'send') || !OW::getAuthorization()->isUserAuthorized($receiveUser, 'credits', 'receive') || !isset($params['id'])) {
         $this->setTemplate(OW::getPluginManager()->getPlugin('base')->getCtrlViewDir() . 'authorization_failed.html');
         return;
     }
     $language = OW::getLanguage();
     $config = OW::getConfig();
     $userId = OW::getUser()->getId();
     $userCredits = USERCREDITS_BOL_CreditsService::getInstance()->getCreditsBalance($userId);
     $this->assign('userCredits', $userCredits);
     $this->assign('receiveUserName', BOL_UserService::getInstance()->getDisplayName($receiveUser));
     $form = new Form('creditForm');
     $element = new TextField('creditPoint');
     $element->setRequired(true);
     $element->setLabel($language->text('credits', 'credits_to_send'));
     $element->addAttribute("style", "width: 100px;");
     $validator = new IntValidator(1, $userCredits);
     $validator->setErrorMessage($language->text('credits', 'credit_value_error'));
     $element->addValidator($validator);
     $form->addElement($element);
     $element = new Submit('sendCredit');
     $element->setValue($language->text('credits', 'send_credits'));
     $form->addElement($element);
     if (OW::getRequest()->isPost()) {
         if ($form->isValid($_POST)) {
             $values = $form->getValues();
             $creditValue = (int) $values['creditPoint'];
             if (CREDITS_BOL_Service::getInstance()->transferCredits($userId, $receiveUser, $creditValue)) {
                 OW::getFeedback()->info($language->text('credits', 'credit_transfer_ok'));
                 $this->redirect(OW::getRouter()->urlForRoute('credits_transfer'));
             } else {
                 OW::getFeedback()->error($language->text('credits', 'credit_transfer_fail'));
             }
         }
     }
     $this->addForm($form);
     $this->setPageHeading($language->text('credits', 'transfer_credits_label'));
     $this->setPageTitle($language->text('credits', 'transfer_credits_label'));
     $this->setPageHeadingIconClass('ow_ic_gear_wheel');
 }
Example #7
0
 public function updateUserInfo()
 {
     //DDoS check
     if (empty($_SESSION['lastUpdateRequestTimestamp'])) {
         $_SESSION['lastUpdateRequestTimestamp'] = time();
     } else {
         if (time() - (int) $_SESSION['lastUpdateRequestTimestamp'] < 3) {
             exit('{error: "Too much requests"}');
         }
     }
     $_SESSION['lastUpdateRequestTimestamp'] = time();
     $service = AJAXIM_BOL_Service::getInstance();
     if ($errorMessage = $service->checkPermissions()) {
         exit(json_encode(array('error' => $errorMessage)));
     }
     /* @var BOL_User $user */
     $user = null;
     $friendship = null;
     if (!empty($_POST['click']) && $_POST['click'] == 'online_now') {
         $user = BOL_UserService::getInstance()->findUserById($_POST['userId']);
         if (!OW::getAuthorization()->isUserAuthorized($user->getId(), 'ajaxim', 'chat')) {
             $info = array('warning' => true, 'message' => OW::getLanguage()->text('ajaxim', 'user_is_not_authorized_chat', array('username' => BOL_UserService::getInstance()->getDisplayName($user->getId()))), 'type' => 'warning');
             exit(json_encode($info));
         }
         $eventParams = array('action' => 'ajaxim_invite_to_chat', 'ownerId' => $user->getId(), 'viewerId' => OW::getUser()->getId());
         try {
             OW::getEventManager()->getInstance()->call('privacy_check_permission', $eventParams);
         } catch (RedirectException $e) {
             $info = array('warning' => true, 'message' => OW::getLanguage()->text('ajaxim', 'warning_user_privacy_friends_only', array('displayname' => BOL_UserService::getInstance()->getDisplayName($user->getId()))), 'type' => 'warning');
             exit(json_encode($info));
         }
         $isFriendsOnlyMode = (bool) OW::getEventManager()->call('plugin.friends');
         if ($isFriendsOnlyMode) {
             $friendship = OW::getEventManager()->call('plugin.friends.check_friendship', array('userId' => OW::getUser()->getId(), 'friendId' => $user->getId()));
             if (empty($friendship)) {
                 $info = array('warning' => true, 'message' => OW::getLanguage()->text('ajaxim', 'warning_user_privacy_friends_only', array('displayname' => BOL_UserService::getInstance()->getDisplayName($user->getId()))), 'type' => 'warning');
                 exit(json_encode($info));
             } else {
                 if ($friendship->getStatus() != 'active') {
                     $info = array('warning' => true, 'message' => OW::getLanguage()->text('ajaxim', 'warning_user_privacy_friends_only', array('displayname' => BOL_UserService::getInstance()->getDisplayName($user->getId()))), 'type' => 'warning');
                     exit(json_encode($info));
                 }
             }
         }
         if (BOL_UserService::getInstance()->isBlocked(OW::getUser()->getId(), $user->getId())) {
             $errorMessage = OW::getLanguage()->text('base', 'user_block_message');
             $info = array('warning' => true, 'message' => $errorMessage, 'type' => 'error');
             exit(json_encode($info));
         }
         $onlineStatus = BOL_UserService::getInstance()->findOnlineStatusForUserList(array($user->getId()));
         if (!$onlineStatus[$user->getId()]) {
             $displayname = BOL_UserService::getInstance()->getDisplayName($user->getId());
             $info = array('warning' => true, 'message' => OW::getLanguage()->text('ajaxim', 'user_went_offline', array('displayname' => $displayname)), 'type' => 'warning');
             exit(json_encode($info));
         }
     } else {
         if (!empty($_POST['userId'])) {
             $user = BOL_UserService::getInstance()->findUserById($_POST['userId']);
         }
     }
     if (empty($user)) {
         exit('{error: "User not found"}');
     }
     $friendship = OW::getEventManager()->call('plugin.friends.check_friendship', array('userId' => OW::getUser()->getId(), 'friendId' => $user->getId()));
     $info = '';
     switch ($_POST['action']) {
         case "open":
             $info['node'] = $user->getId();
             $info = $service->getUserInfoByNode($user, $friendship);
             break;
     }
     exit(json_encode($info));
 }
Example #8
0
    $config->addConfig('vwls', 'availability', 0, 'Availability');
}
if (!$config->configExists('vwls', 'status')) {
    $config->addConfig('vwls', 'status', 'approved', 'status');
}
if (!$config->configExists('vwls', 'member')) {
    $config->addConfig('vwls', 'member', 'all', 'member');
}
if (!$config->configExists('vwls', 'member_list')) {
    $config->addConfig('vwls', 'member_list', '', 'member_list');
}
$baseSwf_url = OW_URL_HOME . 'ow_plugins/vwlivestreaming/ls/';
if (!$config->configExists('vwls', 'baseSwf_url')) {
    $config->addConfig('vwls', 'baseSwf_url', $baseSwf_url, 'baseSwf_url');
}
$dbPref = OW_DB_PREFIX;
// 'permission' consists of
// showCamSettings:advancedCamSettings:configureSource:onlyVideo:noVideo:noEmbeds:showTimer:writeText:privateTextchat:
// fillWindow:writeText2:enableVideo:enableChat:enableUsers:fillWindow2:verboseLevel (16)
$sql = "CREATE TABLE IF NOT EXISTS `" . $dbPref . "vwls_clip` (\n  `id` int(11) NOT NULL auto_increment,\n  `userId` int(11) NOT NULL,\n  `title` varchar(128) NOT NULL default '',\n  `description` text NOT NULL,\n  `modifDatetime` int(11) NOT NULL default '0',\n  `roomLimit` int(11) NOT NULL,\n  `welcome` text NOT NULL,\n  `welcome2` text NOT NULL,\n  `offlineMessage` text NOT NULL,\n  `camWidth` int(11) NOT NULL,\n  `camHeight` int(11) NOT NULL,\n  `camFPS` int(11) NOT NULL,\n  `micRate` int(11) NOT NULL,\n  `soundQuality` int(11) NOT NULL,\n  `camBandwidth` int(11) NOT NULL,\n  `labelColor` varchar(50) NOT NULL,\n  `layoutCode` text NOT NULL,\n  `layoutCode2` text NOT NULL,\n  `filterRegex` text NOT NULL,\n  `filterReplace` text NOT NULL,\n  `floodProtection` int(11) NOT NULL,\n  `floodProtection2` int(11) NOT NULL,\n  `permission` varchar(128) NOT NULL,\n  `status` varchar(50) NOT NULL,\n  `user_list` text NOT NULL,\n  `moderator_list` text NOT NULL,\n  `addDatetime` int(11) NOT NULL default '0',\n  `privacy` varchar(50) NOT NULL default 'everybody',\n  `online` varchar(128) NOT NULL default 'no',\n  `onlineCount` int(11) NOT NULL,\n  `onlineUser` varchar(128) NOT NULL default '',\n  `onlineUsers` varchar(128) NOT NULL default '',\n  PRIMARY KEY  (`id`),\n  KEY `userId` (`userId`)\n) ENGINE=MyISAM  DEFAULT CHARSET=utf8;";
OW::getDbo()->query($sql);
OW::getPluginManager()->addPluginSettingsRouteName('vwls', 'vwls_admin_config');
$authorization = OW::getAuthorization();
$groupName = 'vwls';
$authorization->addGroup($groupName);
$authorization->addAction($groupName, 'add');
$authorization->addAction($groupName, 'view', true);
$authorization->addAction($groupName, 'add_comment');
$authorization->addAction($groupName, 'delete_comment_by_content_owner');
$path = OW::getPluginManager()->getPlugin('vwls')->getRootDir() . 'langs.zip';
BOL_LanguageService::getInstance()->importPrefixFromZip($path, 'vwls');
Example #9
0
 public function updateUserInfo()
 {
     //DDoS check
     if (empty($_SESSION['lastUpdateRequestTimestamp'])) {
         $_SESSION['lastUpdateRequestTimestamp'] = time();
     } else {
         if (time() - (int) $_SESSION['lastUpdateRequestTimestamp'] < 3) {
             exit('{error: "Too much requests"}');
         }
     }
     $_SESSION['lastUpdateRequestTimestamp'] = time();
     $conversationService = MAILBOX_BOL_ConversationService::getInstance();
     if ($errorMessage = $conversationService->checkPermissions()) {
         exit(json_encode(array('error' => $errorMessage)));
     }
     /* @var BOL_User $user */
     $user = null;
     if (!empty($_POST['userId'])) {
         $user = BOL_UserService::getInstance()->findUserById($_POST['userId']);
         if (!$user) {
             $info = array('warning' => true, 'message' => 'User not found', 'type' => 'error');
             exit(json_encode($info));
         }
         if (!OW::getAuthorization()->isUserAuthorized($user->getId(), 'mailbox', 'reply_to_chat_message')) {
             $status = BOL_AuthorizationService::getInstance()->getActionStatus('mailbox', 'reply_to_chat_message', array('userId' => $user->getId()));
             if ($status['status'] == BOL_AuthorizationService::STATUS_DISABLED) {
                 $info = array('warning' => true, 'message' => OW::getLanguage()->text('mailbox', 'user_is_not_authorized_chat', array('username' => BOL_UserService::getInstance()->getDisplayName($user->getId()))), 'type' => 'warning');
                 exit(json_encode($info));
             }
         }
         $eventParams = array('action' => 'mailbox_invite_to_chat', 'ownerId' => $user->getId(), 'viewerId' => OW::getUser()->getId());
         try {
             OW::getEventManager()->getInstance()->call('privacy_check_permission', $eventParams);
         } catch (RedirectException $e) {
             //TODOS return message that has been set in a privacy value
             $info = array('warning' => true, 'message' => OW::getLanguage()->text('mailbox', 'warning_user_privacy_friends_only', array('displayname' => BOL_UserService::getInstance()->getDisplayName($user->getId()))), 'type' => 'warning');
             exit(json_encode($info));
         }
         if (BOL_UserService::getInstance()->isBlocked(OW::getUser()->getId(), $user->getId())) {
             $errorMessage = OW::getLanguage()->text('base', 'user_block_message');
             $info = array('warning' => true, 'message' => $errorMessage, 'type' => 'error');
             exit(json_encode($info));
         }
         if (empty($_POST['checkStatus']) || $_POST['checkStatus'] != 2) {
             $onlineStatus = BOL_UserService::getInstance()->findOnlineStatusForUserList(array($user->getId()));
             if (!$onlineStatus[$user->getId()]) {
                 $displayname = BOL_UserService::getInstance()->getDisplayName($user->getId());
                 $info = array('warning' => true, 'message' => OW::getLanguage()->text('mailbox', 'user_went_offline', array('displayname' => $displayname)), 'type' => 'warning');
                 exit(json_encode($info));
             }
         }
         $info = $conversationService->getUserInfo($user->getId());
         exit(json_encode($info));
     }
     exit;
 }
Example #10
0
 public function onPing(OW_Event $event)
 {
     $eventParams = $event->getParams();
     $params = $eventParams['params'];
     if ($eventParams['command'] != 'ajaxim_ping') {
         return;
     }
     $service = AJAXIM_BOL_Service::getInstance();
     if (empty($_SESSION['lastRequestTimestamp'])) {
         $_SESSION['lastRequestTimestamp'] = (int) $params['lastRequestTimestamp'];
     }
     if ((int) $params['lastRequestTimestamp'] - (int) $_SESSION['lastRequestTimestamp'] < 3) {
         $event->setData(array('error' => "Too much requests"));
     }
     $_SESSION['lastRequestTimestamp'] = (int) $params['lastRequestTimestamp'];
     if (!OW::getUser()->isAuthenticated()) {
         $event->setData(array('error' => "You have to sign in"));
     }
     if (!OW::getRequest()->isAjax()) {
         $event->setData(array('error' => "Ajax request required"));
     }
     $onlinePeople = AJAXIM_BOL_Service::getInstance()->getOnlinePeople(OW::getUser());
     if (!empty($params['lastMessageTimestamps'])) {
         $clientOnlineList = array_keys($params['lastMessageTimestamps']);
     } else {
         $clientOnlineList = array();
     }
     $onlineInfo = array();
     /* @var $user BOL_User */
     foreach ($onlinePeople['users'] as $user) {
         if (!OW::getAuthorization()->isUserAuthorized($user->getId(), 'ajaxim', 'chat') && !OW::getAuthorization()->isUserAuthorized($user->getId(), 'ajaxim')) {
             $onlinePeople['count']--;
             continue;
         }
         if (!in_array($user->getId(), $clientOnlineList)) {
             $friendship = OW::getEventManager()->call('plugin.friends.check_friendship', array('userId' => OW::getUser()->getId(), 'friendId' => $user->getId()));
             $roster = $service->getUserInfoByNode($user, $friendship);
             $roster['show'] = 'chat';
             $roster['status'] = 'online';
             $presence = array('node' => $user->getId(), 'data' => $roster);
             $onlineInfo[] = $presence;
         }
     }
     /* @var $user BOL_User */
     foreach ($clientOnlineList as $userId) {
         if (!array_key_exists($userId, $onlinePeople['users'])) {
             $presence = array('node' => $userId, 'data' => array('status' => 'offline'));
             $onlineInfo[] = $presence;
         }
     }
     switch ($params['action']) {
         case "get":
             $response = array();
             if (!empty($onlineInfo)) {
                 $response['presenceList'] = $onlineInfo;
             }
             if ($onlinePeople['count'] != $params['onlineCount']) {
                 $response['onlineCount'] = $onlinePeople['count'];
             }
             if (!empty($params['lastMessageTimestamps'])) {
                 $messageList = AJAXIM_BOL_Service::getInstance()->findUnreadMessages(OW::getUser(), $params['lastMessageTimestamps']);
                 if (!empty($messageList)) {
                     $response['messageList'] = $messageList;
                     $response['messageListLength'] = count($messageList);
                 }
             }
             $event->setData($response);
             break;
     }
 }
Example #11
0
 /**
  * @param OW_Event $e
  */
 public function onRemoveFavorite(OW_Event $e)
 {
     $params = $e->getParams();
     $userId = (int) $params['userId'];
     $favoriteId = (int) $params['favoriteId'];
     $id = (int) $params['id'];
     if (OW::getConfig()->getValue('ocsfavorites', 'can_view') && OW::getAuthorization()->isUserAuthorized($favoriteId, 'ocsfavorites', 'view_users')) {
         $params = array('entityType' => 'ocsfavorites_add_favorite', 'entityId' => $id);
         $event = new OW_Event('notifications.remove', $params);
         OW::getEventManager()->trigger($event);
     }
 }
Example #12
0
 /**
  *
  * @param array $userId
  * @return array
  */
 public function getNewConversationListForConsoleNotificationMailer($userIdList)
 {
     if (empty($userIdList)) {
         return array();
     }
     $userList = $this->dbo->mergeInClause($userIdList);
     $sql = " SELECT `mess`.`id` as messageId, `mess`.*, `conv`.* FROM `" . $this->getTableName() . "` AS `conv`\n\n\t\t\t\t INNER JOIN `" . MAILBOX_BOL_LastMessageDao::getInstance()->getTableName() . "` AS `last_m`\n\t\t\t\t\t ON (`last_m`.`conversationId` = `conv`.`id`)\n\n            \t INNER JOIN `" . MAILBOX_BOL_MessageDao::getInstance()->getTableName() . "` AS `mess`\n\t\t\t\t \tON ( `last_m`.`initiatorMessageId` = `mess`.id AND ( `last_m`.`initiatorMessageId` > `last_m`.interlocutorMessageId )\n                    OR `last_m`.`interlocutorMessageId` = `mess`.id AND ( `last_m`.`initiatorMessageId` < `last_m`.interlocutorMessageId ) )\n\n\t\t\t     WHERE  `conv`.`notificationSent` = 0 AND ( ( `conv`.`initiatorId` IN ( {$userList} ) AND `last_m`.`interlocutorMessageId` > 0 AND `conv`.`deleted` != " . self::DELETED_INITIATOR . " AND NOT `conv`.`read` & " . self::READ_INITIATOR . "  AND NOT `conv`.`viewed` &  " . self::VIEW_INITIATOR . " )\n\t\t\t\t\t \tOR ( `conv`.`interlocutorId` IN ( {$userList} ) AND `conv`.`deleted` != " . self::DELETED_INTERLOCUTOR . "  AND  NOT `conv`.`read` & " . self::READ_INTERLOCUTOR . " AND NOT `conv`.`viewed` &  " . self::VIEW_INTERLOCUTOR . " ) ) \n        ";
     $conversationList = $this->dbo->queryForList($sql);
     $resultList = array();
     foreach ($conversationList as $conversation) {
         $userId = $conversation['recipientId'];
         if ($conversation['wasAuthorized'] == 0) {
             $actionName = 'read_message';
             if ($conversation['subject'] == 'mailbox_chat_conversation') {
                 $actionName = 'read_chat_message';
             }
             if (!OW::getAuthorization()->isUserAuthorized($userId, 'mailbox', $actionName)) {
                 $status = BOL_AuthorizationService::getInstance()->getActionStatus('mailbox', $actionName);
                 $conversation['text'] = $status['msg'];
             }
         } else {
             if ($conversation['isSystem'] == 1) {
                 $eventParams = json_decode($conversation['text'], true);
                 $eventParams['params']['messageId'] = $conversation['messageId'];
                 $eventParams['params']['getPreview'] = true;
                 $event = new OW_Event($eventParams['entityType'] . '.' . $eventParams['eventName'], $eventParams['params']);
                 OW::getEventManager()->trigger($event);
                 $data = $event->getData();
                 if (!empty($data)) {
                     $conversation['text'] = $data;
                 } else {
                     $conversation['text'] = OW::getLanguage()->text('mailbox', 'can_not_display_entitytype_message', array('entityType' => $eventParams['entityType']));
                 }
             }
         }
         $resultList[$userId][] = $conversation;
     }
     return $resultList;
 }
Example #13
0
<?php

/**
 * Copyright (c) 2014, Skalfa LLC
 * All rights reserved.
 *
 * ATTENTION: This commercial software is intended for exclusive use with SkaDate Dating Software (http://www.skadate.com) and is licensed under SkaDate Exclusive License by Skalfa LLC.
 *
 * Full text of this license can be found at http://www.skadate.com/sel.pdf
 */
$pluginKey = 'hotlist';
$dbPrefix = OW_DB_PREFIX . $pluginKey . '_';
$sql = <<<EOT

CREATE TABLE IF NOT EXISTS `{$dbPrefix}user` (
  `id` int(11) unsigned NOT NULL auto_increment,
  `userId` int(11) NOT NULL,
  `timestamp` int(10) NOT NULL,
  `expiration_timestamp` int(10) NOT NULL,
  PRIMARY KEY  (`id`),
  KEY `userId` (`userId`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

EOT;
OW::getDbo()->query($sql);
OW::getLanguage()->importPluginLangs(OW::getPluginManager()->getPlugin($pluginKey)->getRootDir() . 'langs.zip', $pluginKey);
OW::getPluginManager()->addPluginSettingsRouteName($pluginKey, 'hotlist-admin-settings');
OW::getConfig()->addConfig($pluginKey, 'expiration_time', 86400 * 30);
OW::getAuthorization()->addGroup('hotlist', false);
OW::getAuthorization()->addAction('hotlist', 'add_to_list');
Example #14
0
 * All rights reserved.
 * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
 * following conditions are met:
 *
 *  - Redistributions of source code must retain the above copyright notice, this list of conditions and
 *  the following disclaimer.
 *
 *  - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
 *  the following disclaimer in the documentation and/or other materials provided with the distribution.
 *
 *  - Neither the name of the Oxwall Foundation nor the names of its contributors may be used to endorse or promote products
 *  derived from this software without specific prior written permission.
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
try {
    Updater::getConfigService()->addConfig('questions', 'list_order', 'latest');
    Updater::getConfigService()->addConfig('questions', 'ev_page_visited', 0);
    Updater::getConfigService()->addConfig('questions', 'plugin_installed', 1);
    OW::getAuthorization()->addAction('questions', 'add_answer');
    $widgetService = Updater::getWidgetService();
    $widget = $widgetService->addWidget('QUESTIONS_CMP_IndexWidget', false);
    $widgetService->addWidgetToPlace($widget, 'index');
    Updater::getLanguageService()->importPrefixFromZip(dirname(__FILE__) . DS . 'langs.zip', 'questions');
} catch (Exception $e) {
}
Example #15
0
 public function getUserFriends($userId)
 {
     $friendsCount = FRIENDS_BOL_Service::getInstance()->countFriends($userId);
     $friends = FRIENDS_BOL_Service::getInstance()->findFriendIdList($userId, 0, $friendsCount);
     $list = array();
     foreach ($friends as $friend) {
         if (OW::getAuthorization()->isUserAuthorized($friend, 'credits', 'receive')) {
             $list[$friend] = BOL_UserService::getInstance()->getDisplayName($friend);
         }
     }
     return $list;
 }
Example #16
0
 public function ajaxResponder()
 {
     if (!OW::getAuthorization()->isUserAuthorized(OW::getUser()->getId(), 'admin') || empty($_POST["command"]) || !OW::getRequest()->isAjax()) {
         throw new Redirect404Exception();
     }
     $command = (string) $_POST["command"];
     switch ($command) {
         case 'deleteQuestion':
             $questionId = (int) $_POST['questionId'];
             $question = $this->questionService->findQuestionById($questionId);
             if (empty($question)) {
                 echo json_encode(array('result' => false));
                 exit;
             }
             $parent = null;
             if (!empty($question->parent)) {
                 $parent = $this->questionService->findQuestionByName($question->parent);
             }
             if ($question->base == 1 || !$question->removable || !empty($parent)) {
                 echo json_encode(array('result' => false));
                 exit;
             }
             $childList = $this->questionService->findQuestionChildren($question->name);
             $deleteList = array();
             $deleteQuestionNameList = array();
             foreach ($childList as $child) {
                 $deleteList[] = $child->id;
                 $deleteQuestionNameList[$child->name] = $child->name;
             }
             if (!empty($deleteList)) {
                 $this->questionService->deleteQuestion($deleteList);
             }
             if ($this->questionService->deleteQuestion(array((int) $_POST['questionId']))) {
                 echo json_encode(array('result' => "success", 'message' => OW::getLanguage()->text('admin', 'questions_question_was_deleted'), 'deleteList' => $deleteQuestionNameList));
                 exit;
             }
             echo json_encode(array('result' => false));
             exit;
             break;
         case 'findNearestSection':
             $sectionName = $_POST['sectionName'];
             if (!empty($sectionName)) {
                 $section = $this->questionService->findSectionBySectionName($sectionName);
                 if (empty($section)) {
                     echo json_encode(array('result' => false));
                     exit;
                 }
                 $nearSection = $this->questionService->findNearestSection($section);
                 if (empty($nearSection)) {
                     echo json_encode(array('result' => false));
                     exit;
                 }
                 echo json_encode(array('result' => "success", 'message' => OW::getLanguage()->text('admin', 'questions_delete_section_confirmation_with_move_questions', array('sectionName' => BOL_QuestionService::getInstance()->getSectionLang($nearSection->name)))));
                 exit;
             }
             echo json_encode(array('result' => false));
             exit;
             break;
         case 'deleteSection':
             if (!empty($_POST['sectionName']) && mb_strlen($_POST['sectionName']) > 0) {
                 /*@var $nearSection BOL_QuestionSection*/
                 $nearSection = $this->questionService->findSectionBySectionName($_POST['sectionName']);
                 $moveQuestionsToSection = null;
                 if (!empty($nearSection) && $nearSection->isDeletable && $this->questionService->deleteSection(htmlspecialchars($_POST['sectionName']), $moveQuestionsToSection)) {
                     $result = array('result' => "success", 'message' => OW::getLanguage()->text('admin', 'questions_section_was_deleted'));
                     if (!empty($moveQuestionsToSection)) {
                         $result['moveTo'] = $moveQuestionsToSection->name;
                     }
                     echo json_encode($result);
                     exit;
                 }
             }
             echo json_encode(array('result' => "false"));
             exit;
             break;
         case 'DeleteQuestionValue':
             $result = false;
             $questionId = htmlspecialchars($_POST["questionId"]);
             $question = $this->questionService->findQuestionById($questionId);
             $value = (int) $_POST["value"];
             if (empty($question) || empty($value) && $value !== 0) {
                 echo json_encode(array('result' => $result));
                 return;
             }
             if ($this->questionService->deleteQuestionValue($question->name, $value)) {
                 $result = true;
             }
             echo json_encode(array('result' => $result));
             break;
         case 'deleteAccountType':
             if (!empty($_POST['accountType']) && mb_strlen($_POST['accountType']) > 0) {
                 $accountTypes = $this->questionService->findAllAccountTypes();
                 $accountTypeList = array();
                 foreach ($accountTypes as $key => $account) {
                     if ($account->name != $_POST['accountType']) {
                         $accountTypeList[$account->name] = $account->name;
                     }
                 }
                 if (empty($accountTypeList)) {
                     echo json_encode(array('result' => "false", 'message' => OW::getLanguage()->text('admin', 'questions_cant_delete_last_account_type')));
                     exit;
                 } else {
                     if ($this->questionService->deleteAccountType($_POST['accountType'])) {
                         echo json_encode(array('result' => "success", 'message' => OW::getLanguage()->text('admin', 'questions_account_type_was_deleted')));
                         exit;
                     }
                 }
             }
             echo json_encode(array('result' => "false"));
             exit;
             break;
         case 'AddQuestionValues':
             $result = false;
             $questionId = (int) $_POST["questionId"];
             $question = $this->questionService->findQuestionById($questionId);
             $values = !empty($_POST["values"]) && is_array($_POST["values"]) ? $_POST["values"] : array();
             if (empty($question) || empty($values)) {
                 echo json_encode(array('result' => $result));
                 return;
             }
             if ($this->questionService->updateQuestionValues($question, $values)) {
                 $result = true;
             }
             echo json_encode(array('result' => $result));
             break;
         case 'AddAccountType':
             $result = false;
             $name = htmlspecialchars($_POST["accountTypeName"]);
             $roleId = (int) $_POST["role"];
             $accountType = new BOL_QuestionAccountType();
             $accountType->name = $name;
             $accountType->roleId = $roleId;
             $form = new ADMIN_CLASS_AddAccountTypeForm($accountType);
             $result = false;
             if ($form->isValid($_POST)) {
                 $result = $form->process($_POST);
             }
             echo json_encode(array('result' => $result, 'accountTypeName' => $name, 'roleId' => $roleId));
             break;
         case 'sortAccountType':
             $sortAccountType = json_decode($_POST['accountTypeList'], true);
             $result = false;
             if (isset($sortAccountType) && is_array($sortAccountType) && count($sortAccountType) > 0) {
                 $result = $this->questionService->reOrderAccountType($sortAccountType);
             }
             echo json_encode(array('result' => $result));
             break;
         case 'sortQuestions':
             $sectionName = htmlspecialchars($_POST['sectionName']);
             $sectionQuestionOrder = json_decode($_POST['questionOrder'], true);
             $check = true;
             if (!isset($sectionName)) {
                 $check = false;
             }
             if (!isset($sectionQuestionOrder) || !is_array($sectionQuestionOrder) || !count($sectionQuestionOrder) > 0) {
                 $check = false;
             }
             if ($sectionName === 'no_section') {
                 $sectionName = null;
             }
             $result = false;
             if ($check) {
                 $result = $this->questionService->reOrderQuestion($sectionName, $sectionQuestionOrder);
             }
             echo json_encode(array('result' => $result));
             break;
         case 'sortSection':
             $sectionOrder = json_decode($_POST['sectionOrder'], true);
             if (!isset($sectionOrder) || !is_array($sectionOrder) || !count($sectionOrder) > 0) {
                 return false;
             }
             $result = $this->questionService->reOrderSection($sectionOrder);
             echo json_encode(array('result' => $result));
             break;
         case 'questionPages':
             $question = $_POST['question'];
             $required = $_POST['required'] == 'true';
             $onJoin = $_POST['onJoin'] == 'true';
             $onEdit = $_POST['onEdit'] == 'true';
             $onView = $_POST['onView'] == 'true';
             $onSearch = $_POST['onSearch'] == 'true';
             $changed = !empty($_POST['changed']) ? $_POST['changed'] : null;
             if (empty($question)) {
                 echo json_encode(array('result' => false));
                 exit;
             }
             $questionDto = $this->questionService->findQuestionByName($question);
             if (!empty($questionDto)) {
                 $disableActionList = BOL_QuestionService::getInstance()->getQuestionDisableActionList($questionDto);
                 switch ($changed) {
                     case 'required':
                         if (!$disableActionList['disable_required']) {
                             $questionDto->required = $required;
                         }
                         break;
                     case 'onJoin':
                         if (!$disableActionList['disable_on_join']) {
                             $questionDto->onJoin = $onJoin;
                         }
                         break;
                     case 'onEdit':
                         if (!$disableActionList['disable_on_edit']) {
                             $questionDto->onEdit = $onEdit;
                         }
                         break;
                     case 'onSearch':
                         if (!$disableActionList['disable_on_search']) {
                             $questionDto->onSearch = $onSearch;
                         }
                         break;
                     case 'onView':
                         if (!$disableActionList['disable_on_view']) {
                             $questionDto->onView = $onView;
                         }
                         break;
                     default:
                         if (!$disableActionList['disable_required']) {
                             $questionDto->required = $required;
                         }
                         if (!$disableActionList['disable_on_join']) {
                             $questionDto->onJoin = $onJoin;
                         }
                         if (!$disableActionList['disable_on_edit']) {
                             $questionDto->onEdit = $onEdit;
                         }
                         if (!$disableActionList['disable_on_view']) {
                             $questionDto->onView = $onView;
                         }
                         if (!$disableActionList['disable_on_search']) {
                             $questionDto->onSearch = $onSearch;
                         }
                         break;
                 }
             }
             $this->questionService->saveOrUpdateQuestion($questionDto);
             echo json_encode(json_encode(array('result' => true)));
             break;
         case 'questionAccountTypes':
             $question = $_POST['question'];
             $data = $_POST['data'];
             if (empty($question) || empty($data)) {
                 echo json_encode(array('result' => false));
                 exit;
             }
             $questionDto = $this->questionService->findQuestionByName($question);
             if (!empty($questionDto)) {
                 $disableActionList = BOL_QuestionService::getInstance()->getQuestionDisableActionList($questionDto);
                 if (!$disableActionList['disable_account_type']) {
                     $add = array();
                     $delete = array();
                     foreach ($data as $accountType => $value) {
                         if ($value === "true") {
                             $add[] = $accountType;
                         } else {
                             $delete[] = $accountType;
                         }
                     }
                     if (!empty($delete)) {
                         BOL_QuestionService::getInstance()->deleteQuestionToAccountType($questionDto->name, $delete);
                     }
                     if (!empty($add)) {
                         BOL_QuestionService::getInstance()->addQuestionToAccountType($questionDto->name, $add);
                     }
                 }
             }
             echo json_encode(json_encode(array('result' => true)));
             break;
         case 'addSection':
             if (empty($_POST['section_name'])) {
                 echo json_encode(array('result' => false, 'message' => ''));
                 exit;
             }
             $sectionName = $_POST['section_name'];
             $questionSection = new BOL_QuestionSection();
             $questionSection->name = md5(uniqid());
             $questionSection->sortOrder = $this->questionService->findLastSectionOrder() + 1;
             $this->questionService->saveOrUpdateSection($questionSection);
             BOL_LanguageService::getInstance()->addOrUpdateValue(OW::getLanguage()->getCurrentId(), 'base', 'questions_section_' . $questionSection->name . '_label', htmlspecialchars($sectionName));
             if (OW::getDbo()->getAffectedRows() > 0) {
                 echo json_encode(array('result' => true, 'message' => OW::getLanguage()->text('admin', 'questions_section_was_added')));
             }
             break;
         case 'addQuestion':
             /* @var $form ADMIN_CLASS_AddQuestionForm */
             $form = OW::getClassInstance('ADMIN_CLASS_AddQuestionForm', 'qst_add_form', '');
             $form->process();
             break;
         case 'editQuestion':
             if (empty($_POST['questionId'])) {
                 echo json_encode(array('result' => false, 'errors' => array(), 'message' => OW::getLanguage()->text('admin', 'questions_not_found')));
                 exit;
             }
             $question = BOL_QuestionService::getInstance()->findQuestionById($_POST['questionId']);
             if (empty($question) || !$question instanceof BOL_Question) {
                 echo json_encode(array('result' => false, 'errors' => array(), 'message' => OW::getLanguage()->text('admin', 'questions_not_found')));
                 exit;
             }
             $form = OW::getClassInstance('ADMIN_CLASS_EditQuestionForm', 'qst_edit_form', '');
             $form->loadQuestionData($question);
             $form->process();
             break;
         default:
     }
     exit;
 }
Example #17
0
<?php

$tblPrefix = OW_DB_PREFIX;
$db = Updater::getDbo();
$queryList = array("INSERT INTO  `{$tblPrefix}base_config` ( `key`, `name`, `value`, `description` ) VALUES ( 'base',  'users_count_on_page',  '30', 'Users count on page' )", "INSERT INTO  `{$tblPrefix}base_config` ( `key`, `name`, `value`, `description` ) VALUES ( 'base',  'cron_is_active',  '0', 'Flag showing if cron script is activated after soft install' )", "UPDATE  `{$tblPrefix}base_menu_item` SET  `key` = 'sidebar_menu_item_permission_role' WHERE  `key` = 'sidebar_menu_item_permission_roles'", "INSERT INTO  `{$tblPrefix}base_menu_item` ( `prefix`, `key`,`documentKey`, `type`, `order`, `routePath`, `externalUrl`, `newWindow`, `visibleFor` )\n        VALUES ( 'admin',  'sidebar_menu_item_users_roles',  '',  'admin_users',  '3',  'admin_user_roles', NULL ,  '0',  '3' )", "INSERT IGNORE INTO `{$tblPrefix}base_question_config` (`id`, `questionPresentation`, `name`, `description`, `presentationClass`) VALUES\n    (1, 'date', 'year_range', '', 'YearRange'),\n    (2, 'age', 'year_range', '', 'YearRange'),\n    (3, 'birthdate', 'year_range', '', 'YearRange')", "ALTER TABLE  `{$tblPrefix}base_authorization_role` ADD `displayLabel` TINYINT( 1 ) NULL DEFAULT '0'", "ALTER TABLE  `{$tblPrefix}base_authorization_role` ADD `custom` VARCHAR( 255 ) NULL DEFAULT NULL");
$sqlErrors = array();
foreach ($queryList as $query) {
    try {
        $db->query($query);
    } catch (Exception $e) {
        $sqlErrors[] = $e;
    }
}
try {
    OW::getAuthorization()->addAction('base', 'view_profile', true);
} catch (Exception $e) {
    $sqlErrors[] = $e;
}
UPDATE_LanguageService::getInstance()->importPrefixFromZip(dirname(__FILE__) . DS . 'langs.zip', 'base');
if (!empty($sqlErrors)) {
    //printVar($sqlErrors);
}
Example #18
0
/**
 * This software is intended for use with Oxwall Free Community Software http://www.oxwall.org/ and is
 * licensed under The BSD license.
 * ---
 * Copyright (c) 2011, Oxwall Foundation
 * All rights reserved.
 * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
 * following conditions are met:
 *
 *  - Redistributions of source code must retain the above copyright notice, this list of conditions and
 *  the following disclaimer.
 *
 *  - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
 *  the following disclaimer in the documentation and/or other materials provided with the distribution.
 *
 *  - Neither the name of the Oxwall Foundation nor the names of its contributors may be used to endorse or promote products
 *  derived from this software without specific prior written permission.
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
try {
    OW::getAuthorization()->deleteAction('video', 'delete_comment_by_content_owner');
} catch (Exception $e) {
}
Updater::getLanguageService()->importPrefixFromZip(dirname(__FILE__) . DS . 'langs.zip', 'video');
Example #19
0
 /**
  * Updates forum plugin configuration
  *
  * @return boolean
  */
 public function process()
 {
     $values = $this->getValues();
     $enableAttachmentsValue = empty($values['enableAttachments']) ? false : (bool) $values['enableAttachments'];
     $config = OW::getConfig();
     $enableAttachmentsValue = true;
     //TODO tmp solution, remove this assignment when it will be necessary
     $config->saveConfig('mailbox', 'enable_attachments', $enableAttachmentsValue);
     $config->saveConfig('mailbox', 'show_all_members', 0);
     $send_message_interval = empty($values['send_message_interval']) ? 0 : (int) $values['send_message_interval'];
     $config->saveConfig('mailbox', 'send_message_interval', $send_message_interval);
     $authorization = OW::getAuthorization();
     $groupName = 'mailbox';
     $authorization->deleteAction($groupName, 'read_message');
     $authorization->deleteAction($groupName, 'send_message');
     $authorization->deleteAction($groupName, 'reply_to_message');
     $authorization->deleteAction($groupName, 'read_chat_message');
     $authorization->deleteAction($groupName, 'send_chat_message');
     $authorization->deleteAction($groupName, 'reply_to_chat_message');
     switch ($values['active_mode_list']) {
         case 'chat':
             $modes = array($values['active_mode_list']);
             $config->saveConfig('mailbox', 'active_modes', json_encode($modes));
             $authorization->addAction($groupName, 'read_chat_message');
             $authorization->addAction($groupName, 'send_chat_message');
             $authorization->addAction($groupName, 'reply_to_chat_message');
             break;
         case 'mail':
             $modes = array($values['active_mode_list']);
             $config->saveConfig('mailbox', 'active_modes', json_encode($modes));
             $authorization->addAction($groupName, 'read_message');
             $authorization->addAction($groupName, 'send_message');
             $authorization->addAction($groupName, 'reply_to_message');
             break;
         case 'mailchat':
             $modes = array('mail', 'chat');
             $config->saveConfig('mailbox', 'active_modes', json_encode($modes));
             $authorization->addAction($groupName, 'read_message');
             $authorization->addAction($groupName, 'send_message');
             $authorization->addAction($groupName, 'reply_to_message');
             $authorization->addAction($groupName, 'read_chat_message');
             $authorization->addAction($groupName, 'send_chat_message');
             $authorization->addAction($groupName, 'reply_to_chat_message');
             break;
     }
     if ($values['active_mode_list'] != 'mail') {
         $show_all_members = empty($values['show_all_members']) ? 0 : 1;
         $config->saveConfig('mailbox', 'show_all_members', $show_all_members);
     }
     if (OW::getPluginManager()->isPluginActive('usercredits')) {
         USERCREDITS_BOL_CreditsService::getInstance()->deleteActionsByPluginKey('mailbox');
         $credits = new MAILBOX_CLASS_Credits();
         $credits->triggerCreditActionsAdd();
     }
     return array('result' => true);
 }
Example #20
0
 public function onShowOnlineButton(OW_Event $event)
 {
     $params = $event->getParams();
     if (empty($params['userId'])) {
         return false;
     }
     $activeModes = $this->service->getActiveModeList();
     if (!in_array('chat', $activeModes)) {
         return false;
     }
     if (BOL_UserService::getInstance()->isBlocked($params['userId'], $params['onlineUserId'])) {
         return false;
     }
     $eventParams = array('action' => 'mailbox_invite_to_chat', 'ownerId' => $params['onlineUserId'], 'viewerId' => OW::getUser()->getId());
     try {
         OW::getEventManager()->getInstance()->call('privacy_check_permission', $eventParams);
     } catch (RedirectException $e) {
         return false;
     }
     if (!OW::getAuthorization()->isUserAuthorized($params['userId'], 'mailbox', 'send_chat_message')) {
         return false;
     }
     return true;
 }
Example #21
0
 public function completeInstall()
 {
     if (OW::getConfig()->getValue('equestions', 'plugin_installed')) {
         return;
     }
     $authorization = OW::getAuthorization();
     $groupName = self::PLUGIN_KEY;
     $authorization->addGroup($groupName);
     $authorization->addAction($groupName, 'add_comment');
     $authorization->addAction($groupName, 'ask');
     $authorization->addAction($groupName, 'answer');
     $authorization->addAction($groupName, 'add_answer');
     $authorization->addAction($groupName, 'delete_comment_by_content_owner');
     OW::getPluginManager()->addPluginSettingsRouteName('equestions', 'equestions-admin-main');
     OW::getConfig()->saveConfig('equestions', 'plugin_installed', '1');
 }
Example #22
0
function admin_set_admin_cookie()
{
    if (OW::getAuthorization()->isUserAuthorized(OW_Auth::getInstance()->getUserId(), 'admin') && !isset($_COOKIE['isAdmin'])) {
        setcookie('isAdmin', 1, time() + 3600 * 24 * 300, '/');
    }
}
 /**
  * @param array $params
  * @param array &$result
  * @return array
  */
 public function checkPermission($params)
 {
     if (!isset($params['ownerId'])) {
         throw new InvalidArgumentException('Invalid parameter ownerId!');
     }
     $action = $params['action'];
     $ownerId = (int) $params['ownerId'];
     $viewerId = (int) $params['viewerId'];
     $user = BOL_UserService::getInstance()->findUserById($ownerId);
     if ($user === null) {
         // do not block content if user has been removed
         return array('blocked' => false);
         // TODO: throw exception
         // throw new InvalidArgumentException('Invalid parameter ownerId!');
     }
     $result = array();
     $langParams = array('username' => $user->username, 'display_name' => BOL_UserService::getInstance()->getDisplayName($ownerId));
     $result['blocked'] = true;
     $result['message'] = OW::getLanguage()->getInstance()->text('privacy', 'privacy_no_permission_message', $langParams);
     $eventParams = array('action' => $action, 'ownerId' => $ownerId);
     $privacy = OW::getEventManager()->getInstance()->call('plugin.privacy.get_privacy', $eventParams);
     $result['privacy'] = $privacy;
     $eventParams = array('action' => $action, 'privacy' => $privacy, 'ownerId' => $ownerId, 'viewerId' => $viewerId);
     $event = new BASE_CLASS_EventCollector('plugin.privacy.check_permission', $eventParams);
     OW::getEventManager()->getInstance()->trigger($event);
     $data = $event->getData();
     if (!empty($data)) {
         $data = call_user_func_array('array_merge', $event->getData());
     }
     if (isset($data[$privacy])) {
         $result['blocked'] = false;
         if ($data[$privacy]['blocked']) {
             $result['blocked'] = true;
             if (!empty($data[$privacy]['message'])) {
                 $result['message'] = $data[$privacy]['message'];
             }
         }
     }
     if (OW::getAuthorization()->isUserAuthorized($viewerId, BOL_AuthorizationService::ADMIN_GROUP_NAME)) {
         $result['blocked'] = false;
         return $result;
     }
     $actionDto = $this->findAction($action);
     if (!empty($actionDto) && OW::getAuthorization()->isUserAuthorized($viewerId, $actionDto->pluginKey)) {
         $result['blocked'] = false;
     }
     return $result;
 }
Example #24
0
 * This software is intended for use with Oxwall Free Community Software http://www.oxwall.org/ and is
 * licensed under The BSD license.
 * ---
 * Copyright (c) 2009, Skalfa LLC
 * All rights reserved.
 * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
 * following conditions are met:
 *
 *  - Redistributions of source code must retain the above copyright notice, this list of conditions and
 *  the following disclaimer.
 *
 *  - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
 *  the following disclaimer in the documentation and/or other materials provided with the distribution.
 *
 *  - Neither the name of the Oxwall Foundation nor the names of its contributors may be used to endorse or promote products
 *  derived from this software without specific prior written permission.
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
$dbPrefix = OW_DB_PREFIX;
$sql = "CREATE TABLE IF NOT EXISTS `{$dbPrefix}friends_friendship` (\n  `id` int(11) NOT NULL auto_increment,\n  `userId` int(11) NOT NULL,\n  `friendId` int(11) NOT NULL,\n  `status` enum('active','pending','ignored') NOT NULL default 'pending',\n  `timeStamp` int(11) NOT NULL,\n  `viewed` int(11) NOT NULL,\n  `active` tinyint(4) NOT NULL default '1',\n  `notificationSent` tinyint(4) NOT NULL default '0',\n  PRIMARY KEY  (`id`),\n  UNIQUE KEY `userId_friendId` (`userId`,`friendId`),\n  KEY `friendId` (`friendId`),\n  KEY `userId` (`userId`)\n) ENGINE=MyISAM  DEFAULT CHARSET=utf8";
OW::getDbo()->query($sql);
OW::getLanguage()->importPluginLangs(OW::getPluginManager()->getPlugin('friends')->getRootDir() . 'langs.zip', 'friends');
OW::getAuthorization()->addGroup('friends', false);
OW::getAuthorization()->addAction('friends', 'add_friend');
Example #25
0
 private function getSuggestedMembershipPlan($userId, $pluginKey, $actionKey)
 {
     $membershipService = MEMBERSHIP_BOL_MembershipService::getInstance();
     $authService = BOL_AuthorizationService::getInstance();
     $action = $authService->findAction($pluginKey, $actionKey);
     if (!$action) {
         return null;
     }
     if (OW::getAuthorization()->isUserAuthorized($userId, $pluginKey, $actionKey)) {
         return null;
     }
     // get user account type
     $accTypeName = BOL_UserService::getInstance()->findUserById($userId)->getAccountType();
     $accType = BOL_QuestionService::getInstance()->findAccountTypeByName($accTypeName);
     $typeList = $membershipService->getTypeList($accType->id);
     /*@var $membership MEMBERSHIP_BOL_MembershipUser */
     $membership = $membershipService->getUserMembership($userId);
     $exclude = $membershipService->getUserTrialPlansUsage($userId);
     $plans = $membershipService->getTypePlanList($exclude);
     $permissions = $authService->getPermissionList();
     $suggestedPlanId = null;
     $suggestedPlanPrice = PHP_INT_MAX;
     $suggestedPlanTitle = null;
     $suggestedPlanPeriod = null;
     if (!$typeList) {
         return null;
     }
     foreach ($typeList as $type) {
         if (!isset($plans[$type->id])) {
             continue;
         }
         if (!$this->actionPermittedForMembershipType($action, $type, $permissions)) {
             continue;
         }
         if (!empty($membership) && $membership->typeId == $type->id) {
             continue;
         }
         $used = $membershipService->isTrialUsedByUser($userId);
         foreach ($plans[$type->id] as $plan) {
             if ($used && $plan['dto']->price == 0) {
                 continue;
             }
             /*@var $plan['dto'] MEMBERSHIP_BOL_MembershipPlan*/
             if ($plan['dto']->price < $suggestedPlanPrice) {
                 $suggestedPlanId = $plan['dto']->id;
                 $suggestedPlanPrice = $plan['dto']->price;
                 $suggestedPlanTitle = $plan['plan_format'];
                 $suggestedPlanPrice = $plan['dto']->price;
                 $suggestedPlanPeriod = $plan['dto']->period;
             }
         }
     }
     if ($suggestedPlanId) {
         return array('id' => $suggestedPlanId, 'title' => $suggestedPlanTitle, 'productId' => $membershipService->getPlanProductId($suggestedPlanId), 'price' => $suggestedPlanPrice, 'period' => $suggestedPlanPeriod);
     }
     return null;
 }
Example #26
0
<?php

/**
 * This software is intended for use with Oxwall Free Community Software http://www.oxwall.org/ and is
 * licensed under The BSD license.
 * ---
 * Copyright (c) 2011, Oxwall Foundation
 * All rights reserved.
 * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
 * following conditions are met:
 *
 *  - Redistributions of source code must retain the above copyright notice, this list of conditions and
 *  the following disclaimer.
 *
 *  - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
 *  the following disclaimer in the documentation and/or other materials provided with the distribution.
 *
 *  - Neither the name of the Oxwall Foundation nor the names of its contributors may be used to endorse or promote products
 *  derived from this software without specific prior written permission.
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
$updateDir = dirname(__FILE__) . DS;
Updater::getLanguageService()->importPrefixFromZip($updateDir . 'langs.zip', 'groups');
OW::getAuthorization()->addAction('groups', 'view', true);
Example #27
0
 public function completeInstall()
 {
     $authorization = OW::getAuthorization();
     $groupName = self::PLUGIN_KEY;
     $authorization->addGroup($groupName);
     $authorization->addAction($groupName, 'add_comment');
     $authorization->addAction($groupName, 'ask');
     $authorization->addAction($groupName, 'answer');
     $authorization->addAction($groupName, 'add_answer');
     OW::getPluginManager()->addPluginSettingsRouteName('questions', 'questions-admin-main');
     OW::getConfig()->saveConfig('questions', 'plugin_installed', '1');
 }