/** * Returns an instance of class (singleton pattern implementation). * * @return PRIVACY_BOL_ActionService */ public static function getInstance() { if (self::$classInstance === null) { self::$classInstance = new self(); } return self::$classInstance; }
public function run() { PRIVACY_BOL_ActionService::getInstance()->cronUpdatePrivacy(); }
public function index($params) { $userId = OW::getUser()->getId(); if (OW::getRequest()->isAjax()) { exit; } if (!OW::getUser()->isAuthenticated() || $userId === null) { throw new AuthenticateException(); } $contentMenu = new BASE_CMP_PreferenceContentMenu(); $contentMenu->getElement('privacy')->setActive(true); $this->addComponent('contentMenu', $contentMenu); $language = OW::getLanguage(); $this->setPageHeading($language->text('privacy', 'privacy_index')); $this->setPageHeadingIconClass('ow_ic_lock'); // -- Action form -- $privacyForm = new Form('privacyForm'); $privacyForm->setId('privacyForm'); $actionSubmit = new Submit('privacySubmit'); $actionSubmit->addAttribute('class', 'ow_button ow_ic_save'); $actionSubmit->setValue($language->text('privacy', 'privacy_submit_button')); $privacyForm->addElement($actionSubmit); // -- $actionList = PRIVACY_BOL_ActionService::getInstance()->findAllAction(); $actionNameList = array(); foreach ($actionList as $action) { $actionNameList[$action->key] = $action->key; } $actionValueList = PRIVACY_BOL_ActionService::getInstance()->getActionValueList($actionNameList, $userId); $actionValuesEvent = new BASE_CLASS_EventCollector(PRIVACY_BOL_ActionService::EVENT_GET_PRIVACY_LIST); OW::getEventManager()->trigger($actionValuesEvent); $data = $actionValuesEvent->getData(); $actionValuesInfo = empty($data) ? array() : $data; $optionsList = array(); $sortOptionsList = array(); $order = array(); // -- sort action values foreach ($actionValuesInfo as $value) { $optionsList[$value['key']] = $value['label']; $order[$value['sortOrder']] = $value['key']; } asort($order); foreach ($order as $key) { $sortOptionsList[$key] = $optionsList[$key]; } // -- $resultList = array(); foreach ($actionList as $action) { /* @var $action PRIVACY_CLASS_Action */ if (!empty($action->label)) { $formElement = new Selectbox($action->key); $formElement->setLabel($action->label); $formElement->setDescription(''); if (!empty($action->description)) { $formElement->setDescription($action->description); } $formElement->setOptions($sortOptionsList); $formElement->setHasInvitation(false); if (!empty($actionValueList[$action->key])) { $formElement->setValue($actionValueList[$action->key]); if (array_key_exists($actionValueList[$action->key], $sortOptionsList)) { $formElement->setValue($actionValueList[$action->key]); } else { if ($actionValueList[$action->key] != 'everybody') { $formElement->setValue('only_for_me'); } } } $privacyForm->addElement($formElement); $resultList[$action->key] = $action->key; } } if (OW::getRequest()->isPost()) { if ($privacyForm->isValid($_POST)) { $values = $privacyForm->getValues(); $restul = PRIVACY_BOL_ActionService::getInstance()->saveActionValues($values, $userId); if ($restul) { OW::getFeedback()->info($language->text('privacy', 'action_action_data_was_saved')); } else { OW::getFeedback()->warning($language->text('privacy', 'action_action_data_not_changed')); } $this->redirect(); } } $this->addForm($privacyForm); $this->assign('actionList', $resultList); }
public function checkPremissionForUserList(OW_Event $event) { $params = $event->getParams(); $action = $params['action']; $ownerIdList = $params['ownerIdList']; $viewerId = $params['viewerId']; return PRIVACY_BOL_ActionService::getInstance()->checkPermissionForUserList($action, $ownerIdList, $viewerId); }