/** * @param string $allPreferences * @return UserPreferences */ public static function Parse($allPreferences) { $preferences = new UserPreferences(); if (empty($allPreferences)) { return $preferences; } $pairs = explode('!sep!', $allPreferences); foreach ($pairs as $pair) { $nv = explode('=', $pair); $preferences->Add($nv[0], $nv[1]); } return $preferences; }
function setData($bacs_reference, $payments, &$errors = array(), $data, $plpayment) { $this->bacs_reference = $bacs_reference; $this->payments = $payments; $this->plpayment = $plpayment; $account = DataObjectFactory::Factory('CBAccount'); if (isset($data['cb_account_id'])) { $account->load($data['cb_account_id']); } $this->account = $account; $userPreferences = UserPreferences::instance(EGS_USERNAME); $defaultPrinter = $userPreferences->getPreferenceValue('default_printer', 'shared'); $params = $data['print']; $print_params = array(); $params['printer'] = empty($data['printer']) ? $defaultPrinter : $data['printer']; if (!$this->controller->setPrintParams($params, $print_params, $errors)) { $errors[] = 'Failed to set print parameters'; } $year = date('y'); $create_date = bcadd(date('z'), 1, 0); $this->create_date = $year . str_pad($create_date, 3, '0', STR_PAD_LEFT); $expiry_date = bcadd(date('z', strtotime($this->plpayment->payment_date)), 1, 0); $processing_date = bcadd(date('z', strtotime($this->getProcessDate($plpayment->payment_date))), 1, 0); $this->processing_date = $year . str_pad($processing_date, 3, '0', STR_PAD_LEFT); $this->expiry_date = $year . str_pad($expiry_date, 3, '0', STR_PAD_LEFT); if ($plpayment->override === 'f') { $this->validate(array('payment_date' => un_fix_date($plpayment->payment_date)), $errors); if ($this->processing_date <= $this->create_date) { $errors[] = 'Invalid Processing Date'; } } }
public static function Factory($default_page = null, $requireLogin = true) { $prefs = UserPreferences::Instance(EGS_USERNAME); $default_page = $prefs->getPreferenceValue('default_page', 'shared'); if ($default_page == null) { $ao = AccessObject::Instance(); $default_page = 'module,' . $ao->getDefaultModule(); } if (get_config('SETUP')) { if (defined('MODULE')) { $default_page = MODULE; } } $router = RouteParser::Instance(); $modules = array(); if (!$requireLogin || isLoggedIn()) { foreach ($router->getDispatch() as $key => $dispatch) { if (($key == 'group' || $key == 'module' || strstr($key, 'submodule')) && !empty($dispatch)) { $modules[$key] = $dispatch; } } if (empty($modules)) { // Default page contains permission type and permission name // i.e. type is group or module $array = explode(',', $default_page); $modules[$array[0]] = $array[1]; } } else { $modules['module'] = 'login'; } $al =& AutoLoader::Instance(); return $modules; }
function __construct($getCurrentValues = true) { parent::__construct(); $userPreferences = UserPreferences::instance(); $this->setModuleName('contacts'); $roleCollection = new RoleCollection(); $sh = new SearchHandler($roleCollection, false); $sh->AddConstraint(new Constraint('usercompanyid', '=', EGS_COMPANY_ID)); $sh->setOrderby('name'); $roleCollection->load($sh); $roles = array(); foreach ($roleCollection->getContents() as $role) { $roles[$role->id] = array('value' => $role->id, 'label' => $role->name); if ($getCurrentValues) { if (in_array($role->id, $userPreferences->getPreferenceValue('default-read-roles', 'contacts'))) { $roles[$role->id]['selected'] = true; } } } $this->registerPreference(array('name' => 'default-read-roles', 'display_name' => 'Default Read Access', 'type' => 'select_multiple', 'data' => $roles, 'default' => array())); foreach ($roleCollection->getContents() as $role) { $roles[$role->id] = array('value' => $role->id, 'label' => $role->name); if ($getCurrentValues) { if (in_array($role->id, $userPreferences->getPreferenceValue('default-write-roles', 'contacts'))) { $roles[$role->id]['selected'] = true; } } } $this->registerPreference(array('name' => 'default-write-roles', 'display_name' => 'Default Write Access', 'type' => 'select_multiple', 'data' => $roles, 'default' => array())); }
function __construct($getCurrentValues = true) { parent::__construct(); $userPreferences = UserPreferences::instance(); $this->setModuleName('calendar'); $view = 'day'; if ($getCurrentValues) { $view = $userPreferences->getPreferenceValue('default-calendar-view', 'calendar'); } $this->registerPreference(array('name' => 'default-calendar-view', 'display_name' => 'Default View', 'type' => 'select', 'value' => $view, 'data' => array(array('label' => 'Day', 'value' => 'day'), array('label' => 'Week', 'value' => 'week'), array('label' => 'Month', 'value' => 'month')), 'default' => 'week')); }
public function Index() { $userPreferences = UserPreferences::instance(EGS_USERNAME); if ($userPreferences->userCanSetPreferences() && !$userPreferences->userHasPreferences()) { $message = "<strong>Welcome to EGS. It looks like this is your first time using the system, or you have not yet got round to setting your preferences.</strong><br />\n You can <a href=\"/?module=dashboard&controller=preferences\">setup your preferences now</a>, or use the 'Preferences' link that is available in the top right of your screen when using the system."; $this->view->set("info_message", $message); } parent::index(); $this->view->set('usealternative', false); $this->view->set('page_title', $this->getPageName()); }
public static function hasNotification($userId, $preferencesId) { $criteria = new CDbCriteria(); $criteria->condition = 'user_id=:userId AND preferences_id=:preferencesId'; $criteria->params = array(':userId' => $userId, ':preferencesId' => $preferencesId); $userPreferences = UserPreferences::model()->find($criteria); if ($userPreferences) { return true; } else { return false; } }
function smarty_function_advanced_search($params, &$smarty) { $data = array('action' => ''); $self = $smarty->getTemplateVars('self'); unset($self['pid'], $self['module'], $self['modules'], $self['controller'], $self['action']); $data['additional_data'] = $self; if (isset($params['action'])) { $data['action'] = $params['action']; } $userPreferences = UserPreferences::instance(); $pdf_browser_printing = $userPreferences->getPreferenceValue('pdf-browser-printing', 'shared'); if (!empty($pdf_browser_printing) && $pdf_browser_printing == 'on') { $data['additional_data']['printaction'] = 'quick_output'; } // fetch smarty plugin template return smarty_plugin_template($smarty, $data, 'function.advanced_search'); }
public function save() { $module = $this->getPreferenceClass($this->_data['__moduleName']); $preferenceNames = $module->getPreferenceNames(); $flash = Flash::Instance(); $userPreferences = UserPreferences::instance(); // FIXME: Validate incomming data against supplied values foreach ($preferenceNames as $preferenceName) { if (isset($this->_data[$preferenceName])) { $pref = $module->getPreference($preferenceName); if (isset($pref['type']) && $pref['type'] == 'numeric') { if (!is_numeric($this->_data[$preferenceName])) { $flash->addError($pref['display_name'] . ' must be numeric'); continue; } } $userPreferences->setPreferenceValue($preferenceName, $this->_data['__moduleName'], $this->_data[$preferenceName]); } else { $preference = $module->getPreference($preferenceName); switch ($preference['type']) { case 'checkbox': $userPreferences->setPreferenceValue($preferenceName, $this->_data['__moduleName'], 'off'); break; case 'select_multiple': $userPreferences->setPreferenceValue($preferenceName, $this->_data['__moduleName'], array()); break; } } } $handled = $module->getHandledPreferences(); foreach ($handled as $name => $preference) { if (!empty($this->_data[$name]) && isset($preference['callback'])) { $callback = array($module, $preference['callback']); call_user_func($callback, $this->_data); } } // Do stuff. $flash->addMessage(prettify($this->_data['__moduleName']) . ' preferences saved successfully'); sendTo('', '', $this->_modules); }
/** * save the data sended by a user profile modification */ function saveUserData($id_user, $data, $also_preference, $also_extra_field) { if (!$this->acl_man->updateUser($id_user, isset($data['userid']) ? $data['userid'] : false, $data['firstname'], $data['lastname'], isset($data['new_pwd']) && $data['new_pwd'] != '' && $data['new_pwd'] == $data['repeat_pwd'] ? $data['new_pwd'] : false, $data['email'], FALSE, $data['signature'], FALSE, FALSE, isset($data['force_change']) ? $data['force_change'] : '', $data['facebook_id'], $data['twitter_id'], $data['linkedin_id'], $data['google_id'])) { return false; } if (isset($data['level'])) { $acl_man =& Docebo::user()->getAclManager(); $current_level = $acl_man->getUserLevelId($id_user); if ($data['level'] != $current_level) { $arr_levels = $acl_man->getAdminLevels(); $acl_man->addToGroup($arr_levels[$data['level']], $id_user); $acl_man->removeFromGroup($arr_levels[$current_level], $id_user); } } if ($also_extra_field) { require_once $GLOBALS['where_framework'] . '/lib/lib.field.php'; $extra_field = new FieldList(); if (!$extra_field->storeFieldsForUser($id_user)) { return false; } } if ($also_preference) { require_once _base_ . '/lib/lib.preference.php'; $preference = new UserPreferences($id_user); if (!$preference->savePreferences($_POST, 'ui.')) { return false; } } return true; }
/** * @param $referenceNumber string * @param $startDate Date * @param $endDate Date * @param $resourceName string * @param $resourceId int * @param $reservationId int * @param $userLevelId int|ReservationUserLevel * @param $title string * @param $description string * @param $scheduleId int * @param $userFirstName string * @param $userLastName string * @param $userId int * @param $userPhone string * @param $userPosition string * @param $userOrganization string * @param $participant_list string * @param $invitee_list string * @param $attribute_list string * @param $preferences string */ public function __construct($referenceNumber = null, $startDate = null, $endDate = null, $resourceName = null, $resourceId = null, $reservationId = null, $userLevelId = null, $title = null, $description = null, $scheduleId = null, $userFirstName = null, $userLastName = null, $userId = null, $userPhone = null, $userOrganization = null, $userPosition = null, $participant_list = null, $invitee_list = null, $attribute_list = null, $preferences = null) { $this->ReferenceNumber = $referenceNumber; $this->StartDate = $startDate; $this->EndDate = $endDate; $this->ResourceName = $resourceName; $this->ResourceId = $resourceId; $this->ReservationId = $reservationId; $this->Title = $title; $this->Description = $description; $this->ScheduleId = $scheduleId; $this->FirstName = $userFirstName; $this->OwnerFirstName = $userFirstName; $this->LastName = $userLastName; $this->OwnerLastName = $userLastName; $this->OwnerPhone = $userPhone; $this->OwnerOrganization = $userOrganization; $this->OwnerPosition = $userPosition; $this->UserId = $userId; $this->UserLevelId = $userLevelId; if (!empty($startDate) && !empty($endDate)) { $this->Date = new DateRange($startDate, $endDate); } if (!empty($participant_list)) { $this->ParticipantIds = explode(',', $participant_list); } if (!empty($invitee_list)) { $this->InviteeIds = explode(',', $invitee_list); } $this->Attributes = CustomAttributes::Parse($attribute_list); $this->UserPreferences = UserPreferences::Parse($preferences); }
function save() { $userPreferences = UserPreferences::instance(); $userPreferences->setPreferenceValue($this->name, '_pagelists', $this->queue); }
public function view() { if (isset($this->_data['username'])) { $username = $this->_data['username']; $res = $this->_uses[$this->modeltype]->load($username); if ($res === FALSE) { sendBack(); } } else { $this->dataError(); sendBack(); } $this->view->set('companies', $res->getCompanies()); $this->view->set('roles', $res->getCompanyRoles()); // Get preferences based on username $prefs = UserPreferences::getPreferencesClass($username); $uzlets = $prefs->getDashboardContents($username); // Manipulate and combine the available and selected uzlets // for display foreach ($uzlets['available'] as $modules => $module) { foreach ($module as $detail) { if (isset($dashboard['available'][$modules])) { $dashboard['available'][$modules] += $detail; } else { $dashboard['available'][$modules] = $detail; } } } foreach ($uzlets['selected'] as $module => $details) { foreach ($details as $selected) { $dashboard['available'][$module][$selected['name']] = $dashboard['current'][$module][$selected['name']] = $selected['title']; } asort($dashboard['available'][$module]); } ksort($dashboard['available']); $this->view->set('dashboard', $dashboard); $shared_prefs['shared']['items_per_page'] = $prefs->getPreferenceValue('items-per-page', 'shared'); $shared_prefs['shared']['pdf_preview'] = $prefs->getPreferenceValue('pdf-preview', 'shared'); $shared_prefs['shared']['pdf_browser-printing'] = $prefs->getPreferenceValue('pdf-browser-printing', 'shared'); $shared_prefs['shared']['default_page'] = $prefs->getPreferenceValue('default_page', 'shared'); $default_printer = $prefs->getPreferenceValue('default_printer', 'shared'); $printers = $this->selectPrinters(); if (isset($printers[$default_printer])) { $shared_prefs['shared']['default_printer'] = $printers[$default_printer]; } else { $shared_prefs['shared']['default_printer'] = ''; } $this->view->set('preferences', $shared_prefs); $this->addSidebar($username); }
static function getPreferencesClass($username = EGS_USERNAME) { if ($username == EGS_USERNAME) { // get preferences for logged in user $prefs =& UserPreferences::instance($username); } else { // get preferences for named user $prefs =& ManagedUserPreferences::instance($username); } return $prefs; }
function adminManager_lang_course() { checkPerm('view'); require_once _base_ . '/lib/lib.form.php'; $lang =& DoceboLanguage::createInstance('adminrules', 'framework'); $adminidst = importVar('adminidst', true, 0); $user_pref = new UserPreferences($adminidst); if (isset($_POST['save'])) { $re = $user_pref->setPreference('admin_rules.user_lang_assigned', isset($_POST['admin_lang']) ? urlencode(serialize($_POST['admin_lang'])) : ''); Util::jump_to('index.php?modname=admin_manager&op=view&result=' . ($re ? 1 : 0)); } $all_languages = Docebo::langManager()->getAllLangCode(); $assigned_lang = unserialize(urldecode($user_pref->getAdminPreference('admin_rules.user_lang_assigned'))); $GLOBALS['page']->add(getTitleArea($lang->def('_ADMIN_MANAGMENT'), 'admin_managmer', $lang->def('_ADMIN_MANAGMENT')) . '<div class="std_block">' . Form::getFormHeader($lang->def('_SELECT_LANG_TO_ASSIGN')) . Form::openForm('admin_lang_editing', 'index.php?modname=admin_manager&op=edit_lang') . Form::openElementSpace() . Form::getHidden('adminidst', 'adminidst', $adminidst), 'content'); while (list(, $lang_code) = each($all_languages)) { $GLOBALS['page']->add(Form::getCheckbox('<img src="' . getPathImage('cms') . 'language/' . $lang_code . '.png" alt="' . $lang_code . '" /> ' . $lang_code, 'admin_lang_' . $lang_code, 'admin_lang[' . $lang_code . ']', '1', isset($assigned_lang[$lang_code])), 'content'); } $GLOBALS['page']->add(Form::closeElementSpace() . Form::openButtonSpace() . Form::getButton('save', 'save', $lang->def('_SAVE')) . Form::getButton('undo_pref', 'undo_pref', $lang->def('_UNDO')) . Form::closeButtonSpace() . Form::closeForm() . '</div>', 'content'); }
function getCalendars() { $userPreferences = UserPreferences::instance(); $view = $userPreferences->getPreferenceValue('default-calendar-view', 'calendar'); $display_options = unserialize($userPreferences->getPreferenceValue('display-calendar-filter', 'calendar')); $calendars = array(); $calendars = $this->getCalendarList($display_options); echo json_encode($calendars); exit; }
public function createUser($params, $userdata) { if (defined("_API_DEBUG") && _API_DEBUG) { file_put_contents('create_user.txt', "\n\n----------------\n\n" . print_r($params, true) . " || " . print_r($userdata, true), FILE_APPEND); } $set_idst = isset($params['idst']) ? $params['idst'] : false; //fix grifomultimedia soap argument [auth a.b.] $userdata = !isset($userdata['userid']) && isset($params) ? $params : $userdata; if (!isset($userdata['userid'])) { return false; } $id_user = $this->aclManager->registerUser($userdata['userid'], isset($userdata['firstname']) ? $userdata['firstname'] : '', isset($userdata['lastname']) ? $userdata['lastname'] : '', isset($userdata['password']) ? $userdata['password'] : '', isset($userdata['email']) ? $userdata['email'] : '', '', isset($userdata['signature']) ? $userdata['signature'] : '', false, $set_idst, isset($userdata['pwd_expire_at']) ? $userdata['pwd_expire_at'] : ''); // suspend if (isset($userdata['valid']) && $userdata['valid'] == '0') { $res = $this->aclManager->suspendUser($id_user); } // registration code: if ($id_user && !empty($userdata['reg_code']) && !empty($userdata['reg_code_type'])) { require_once _base_ . '/lib/lib.usermanager.php'; $user_manager = new UserManager(); $uma = new UsermanagementAdm(); $reg_code_res = $user_manager->_render->processRegistrationCode($this->aclManager, $uma, $id_user, $userdata['reg_code'], $userdata['reg_code_type']); if ($reg_code_res['success'] == false) { $this->aclManager->deleteUser($id_user); $output = array('success' => false, 'message' => 'Registration Code Error: ' . $reg_code_res['msg']); $id_user = false; return $output; } } if (!$id_user) { if (defined("_API_DEBUG") && _API_DEBUG) { file_put_contents('create_user.txt', "?!: " . var_export($id_user, true), FILE_APPEND); } return false; } if ($id_user) { if (!isset($userdata['role'])) { $level = ADMIN_GROUP_USER; } else { switch ($userdata['role']) { case 'godadmin': $level = ADMIN_GROUP_GODADMIN; break; case 'admin': $level = ADMIN_GROUP_ADMIN; break; case 'pubadmin': $level = ADMIN_GROUP_PUBLICADMIN; break; default: $level = ADMIN_GROUP_USER; break; } } //subscribe to std groups $group = $this->aclManager->getGroupST($level); //'/framework/level/user'); $this->aclManager->addToGroup($group, $id_user); $group = $this->aclManager->getGroupST('/oc_0'); $this->aclManager->addToGroup($group, $id_user); $group = $this->aclManager->getGroupST('/ocd_0'); $this->aclManager->addToGroup($group, $id_user); if (isset($userdata['language'])) { require_once _base_ . '/lib/lib.preference.php'; $user_pref = new UserPreferences($id_user); $user_pref->setLanguage($userdata['language']); } //check if some additional fields have been set $okcustom = true; if (isset($userdata['_customfields'])) { require_once _adm_ . '/lib/lib.field.php'; $fields =& $userdata['_customfields']; if (count($fields) > 0) { $fl = new FieldList(); $okcustom = $fl->storeDirectFieldsForUser($id_user, $fields); } } $entities = array(); if (isset($userdata['orgchart'])) { $branches = explode(";", $userdata['orgchart']); if (is_array($branches)) { foreach ($branches as $branch) { $idOrg = $this->_getBranch($branch); if ($idOrg !== false) { $oc = $this->aclManager->getGroupST('/oc_' . $idOrg); $ocd = $this->aclManager->getGroupST('/ocd_' . $idOrg); $this->aclManager->addToGroup($oc, $id_user); $this->aclManager->addToGroup($ocd, $id_user); $entities[$oc] = $oc; $entities[$ocd] = $ocd; } } } } $enrollrules = new EnrollrulesAlms(); $enrollrules->newRules('_NEW_USER', array($id_user), $userdata['language'], 0, !empty($entities) ? $entities : false); // save external user data: if ($params['ext_not_found'] && !empty($params['ext_user']) && !empty($params['ext_user_type'])) { $pref_path = 'ext.user.' . $params['ext_user_type']; $pref_val = 'ext_user_' . $params['ext_user_type'] . "_" . (int) $params['ext_user']; $pref = new UserPreferencesDb(); $pref->assignUserValue($id_user, $pref_path, $pref_val); if (defined("_API_DEBUG") && _API_DEBUG) { file_put_contents('create_user.txt', print_r($id_user, true) . " || " . print_r($pref_path, true) . " || " . print_r($pref_val, true), FILE_APPEND); } } else { if (defined("_API_DEBUG") && _API_DEBUG) { file_put_contents('create_user.txt', "??: \n\n" . print_r($params, true), FILE_APPEND); } } } return $id_user; }
function get($name) { if ($name == 'emailVerified') { return 1; } if ($name == 'email') { return user_getemail(user_getid()); } return parent::get($name); }
function approveusers() { checkPerm('moderate', false, 'course'); require_once $GLOBALS['where_lms'] . '/lib/lib.course.php'; require_once _base_ . '/lib/lib.preference.php'; $id_course = importVar('id_course', true, 0); $course_info = Man_Course::getCourseInfo($id_course); $edition_id = getCourseEditionId(); $re = true; $approve_user = array(); $deny_user = array(); if (isset($_POST['waiting_user'])) { $man_course = new Man_Course(); $waiting_users =& $man_course->getWaitingSubscribed($id_course); $tot_deny = array(); require_once _lms_ . '/lib/lib.course.php'; $docebo_course = new DoceboCourse($id_course); $group_levels = $docebo_course->getCourseLevel($id_course); while (list($id_user, $action) = each($_POST['waiting_user'])) { if ($action == 0) { // approved ----------------------------------------------- $text_query = "\r\n\t\t\t\tUPDATE " . $GLOBALS['prefix_lms'] . "_courseuser\r\n\t\t\t\tSET waiting = 0, \r\n\t\t\t\t\tstatus = '" . _CUS_SUBSCRIBED . "'\r\n\t\t\t\tWHERE idCourse = '" . $id_course . "' AND idUser = '******' "; $text_query .= "AND edition_id='" . $edition_id . "'"; $result = sql_query($text_query); if ($result) { $approve_user[] = $id_user; } $re &= $result; } elseif ($action == 1) { // refused -------------------------------------------------- $level = $waiting_users['users_info'][$id_user]['level']; $sub_by = $waiting_users['users_info'][$id_user]['subscribed_by']; $result = removeSubscription($id_course, $id_user, $group_levels[$level], $edition_id); if ($sub_by != 0 && $id_user != $sub_by) { if (isset($tot_deny[$sub_by])) { $tot_deny[$sub_by]++; } else { $tot_deny[$sub_by] = 1; } } if ($result) { $deny_user[] = $id_user; } $re &= $result; } } } if (!empty($tot_deny)) { while (list($id_user, $inc) = each($tot_deny)) { $pref = new UserPreferences($id_user); $max_subscribe = $pref->getAdminPreference('admin_rules.max_course_subscribe'); $pref->setPreference('admin_rules.max_course_subscribe', $max_subscribe + $inc); } } require_once _base_ . '/lib/lib.eventmanager.php'; $array_subst = array('[url]' => Get::sett('url'), '[course]' => $course_info['name']); if (!empty($approve_user)) { $msg_composer = new EventMessageComposer(); $msg_composer->setSubjectLangText('email', '_APPROVED_SUBSCRIBED_SUBJECT', false); $msg_composer->setBodyLangText('email', '_APPROVED_SUBSCRIBED_TEXT', $array_subst); $msg_composer->setBodyLangText('email', "\n\n" . $_POST['subscribe_accept'], array(), true); $msg_composer->setBodyLangText('sms', '_APPROVED_SUBSCRIBED_TEXT_SMS', $array_subst); // send message to the user subscribed createNewAlert('UserCourseInserted', 'subscribe', 'approve', '1', 'User course approve', $approve_user, $msg_composer, true); } if (!empty($deny_user)) { $msg_composer = new EventMessageComposer(); $msg_composer->setSubjectLangText('email', '_DENY_SUBSCRIBED_SUBJECT', false); $msg_composer->setBodyLangText('email', '_DENY_SUBSCRIBED_TEXT', $array_subst); $msg_composer->setBodyLangText('email', "\n\n" . $_POST['subscribe_refuse'], array(), true); $msg_composer->setSubjectLangText('sms', '_DENY_SUBSCRIBED_SUBJECT_SMS', false); $msg_composer->setBodyLangText('sms', '_DENY_SUBSCRIBED_TEXT_SMS', $array_subst); // send message to the user subscribed createNewAlert('UserCourseInserted', 'subscribe', 'deny', '1', 'User course deny', $deny_user, $msg_composer, true); } backcourse($re ? 'ok' : 'err'); }
public function callback() { return false; $pl = Get::gReq('pl', DOTY_STRING); switch ($pl) { case "twitter": $twitter = new EpiTwitter($this->conf['twitter_key'], $this->conf['twitter_secret']); $oauth_token = Get::gReq('oauth_token', DOTY_STRING); $twitter->setToken($oauth_token); $resp = $twitter->getAccessToken(); echo $resp->oauth_token . "<br />"; echo $resp->oauth_token_secret . "<br />"; var_dump($resp->oauth_callback_confirmed); echo "<br />"; $twitter->setToken($resp->oauth_token, $resp->oauth_token_secret); require_once _base_ . '/lib/lib.preference.php'; $preference = new UserPreferences(getLogUserId()); $preference->setPreference('social.twitter_key', $resp->oauth_token); $preference->setPreference('social.twitter_secret', $resp->oauth_token_secret); $statusText = 'Prova 01'; //$res =$twitter->post('/statuses/update.json', array('status' => $statusText)); //echo $res->text; break; } }
} } else { // user is already logged in, so connect the account with user $social->connectAccount('twitter', $userInfo->screen_name); Util::jump_to('index.php?r=lms/elearning/show'); die; } } else { Util::jump_to('index.php?access_fail=3'); } break; case "linkedin_login": $social = new Social(); $social->includeLinkedinLib(); require_once _base_ . '/lib/lib.preference.php'; $preference = new UserPreferences(getLogUserId()); $conf = $social->getConfig(); $user_pref = array(); if (Docebo::user()->isAnonymous()) { $user_pref['linkedin_key'] = ''; $user_pref['linkedin_secret'] = ''; } else { $user_pref['linkedin_key'] = $preference->getPreference('social.linkedin_key'); $user_pref['linkedin_secret'] = $preference->getPreference('social.linkedin_secret'); } $already_auth = $social->checkLinkedinAuth($conf['linkedin_key'], $conf['linkedin_secret'], $user_pref['linkedin_key'], $user_pref['linkedin_secret']); $sign_in = false; if ($already_auth) { $sign_in = true; } else { if (!isset($_GET['back'])) {
function save() { if (isset($this->_data['eglets']) && count($this->_data['eglets']) > 0) { $prefs = UserPreferences::getPreferencesClass($this->getUser()); $prefs->setPreferenceValue('dashboard_contents', $this->dashboard_module, $this->_data['eglets']); $flash = Flash::Instance(); $flash->addMessage('Dashboard preferences set'); // ATTN: see above for the reason for this commenting # $cache = Cache::Instance(); # $cache->delete(array('eglet_store', $this->module)); } sendTo($_SESSION['refererPage']['controller'], $_SESSION['refererPage']['action'], $_SESSION['refererPage']['modules'], isset($_SESSION['refererPage']['other']) ? $_SESSION['refererPage']['other'] : null); }
public static function Create($row) { $user = new UserItemView(); $user->Id = $row[ColumnNames::USER_ID]; $user->Username = $row[ColumnNames::USERNAME]; $user->First = $row[ColumnNames::FIRST_NAME]; $user->Last = $row[ColumnNames::LAST_NAME]; $user->Email = $row[ColumnNames::EMAIL]; $user->Phone = $row[ColumnNames::PHONE_NUMBER]; $user->DateCreated = Date::FromDatabase($row[ColumnNames::USER_CREATED]); $user->LastLogin = Date::FromDatabase($row[ColumnNames::LAST_LOGIN]); $user->StatusId = $row[ColumnNames::USER_STATUS_ID]; $user->Timezone = $row[ColumnNames::TIMEZONE_NAME]; $user->Organization = $row[ColumnNames::ORGANIZATION]; $user->Position = $row[ColumnNames::POSITION]; $user->Language = $row[ColumnNames::LANGUAGE_CODE]; if (isset($row[ColumnNames::ATTRIBUTE_LIST])) { $user->Attributes = CustomAttributes::Parse($row[ColumnNames::ATTRIBUTE_LIST]); } else { $user->Attributes = new CustomAttributes(); } if (isset($row[ColumnNames::USER_PREFERENCES])) { $preferences = UserPreferences::Parse($row[ColumnNames::USER_PREFERENCES]); if (!empty($preferences)) { $user->ReservationColor = $preferences->Get(UserPreferences::RESERVATION_COLOR); } $user->Preferences = $preferences; } else { $user->Preferences = new UserPreferences(); } return $user; }
/** * Obtener el tema visual del usuario * * @return string */ private function getUserTheme() { return Session::getUserId() > 0 ? UserPreferences::getPreferences(Session::getUserId())->getTheme() : ''; }
/** * @param $referenceNumber string * @param $startDate Date * @param $endDate Date * @param $resourceName string * @param $resourceId int * @param $reservationId int * @param $userLevelId int|ReservationUserLevel * @param $title string * @param $description string * @param $scheduleId int * @param $userFirstName string * @param $userLastName string * @param $userId int * @param $userPhone string * @param $userPosition string * @param $userOrganization string * @param $participant_list string * @param $invitee_list string * @param $attribute_list string * @param $preferences string */ public function __construct($referenceNumber = null, $startDate = null, $endDate = null, $resourceName = null, $resourceId = null, $reservationId = null, $userLevelId = null, $title = null, $description = null, $scheduleId = null, $userFirstName = null, $userLastName = null, $userId = null, $userPhone = null, $userOrganization = null, $userPosition = null, $participant_list = null, $invitee_list = null, $attribute_list = null, $preferences = null, $statusId = null) { $this->ReferenceNumber = $referenceNumber; $this->StartDate = $startDate; $this->EndDate = $endDate; $this->ResourceName = $resourceName; $this->ResourceId = $resourceId; $this->ReservationId = $reservationId; $this->Title = $title; $this->Description = $description; $this->ScheduleId = $scheduleId; $this->FirstName = $userFirstName; $this->OwnerFirstName = $userFirstName; $this->LastName = $userLastName; $this->OwnerLastName = $userLastName; $this->OwnerPhone = $userPhone; $this->OwnerOrganization = $userOrganization; $this->OwnerPosition = $userPosition; $this->UserId = $userId; $this->UserLevelId = $userLevelId; $this->StatusId = $statusId; if (!empty($startDate) && !empty($endDate)) { $this->Date = new DateRange($startDate, $endDate); } if (!empty($participant_list)) { $participants = explode('!sep!', $participant_list); foreach ($participants as $participant) { $pair = explode('=', $participant); $id = $pair[0]; $name = $pair[1]; $name_parts = explode(' ', $name); $this->ParticipantIds[] = $id; $this->ParticipantNames[$id] = new FullName($name_parts[0], $name_parts[1]); } } if (!empty($invitee_list)) { $invitees = explode('!sep!', $invitee_list); foreach ($invitees as $invitee) { $pair = explode('=', $invitee); $id = $pair[0]; $name = $pair[1]; $name_parts = explode(' ', $name); $this->InviteeIds[] = $id; $this->InviteeNames[$id] = new FullName($name_parts[0], $name_parts[1]); } } $this->Attributes = CustomAttributes::Parse($attribute_list); $this->UserPreferences = UserPreferences::Parse($preferences); }
/** * perform an insert of a preference object into the DB * @param integer $p_user_id A valid user identifier. * @param integer $p_project_id A valid project identifier. * @param UserPreferences $p_prefs An UserPrefences Object. * @return boolean */ function user_pref_insert($p_user_id, $p_project_id, UserPreferences $p_prefs) { static $s_vars; $c_user_id = (int) $p_user_id; $c_project_id = (int) $p_project_id; user_ensure_unprotected($p_user_id); if ($s_vars == null) { $s_vars = getClassProperties('UserPreferences', 'protected'); } $t_values = array(); $t_params[] = db_param(); # user_id $t_values[] = $c_user_id; $t_params[] = db_param(); # project_id $t_values[] = $c_project_id; foreach ($s_vars as $t_var => $t_val) { array_push($t_params, db_param()); array_push($t_values, $p_prefs->Get($t_var)); } $t_vars_string = implode(', ', array_keys($s_vars)); $t_params_string = implode(',', $t_params); $t_query = 'INSERT INTO {user_pref} (user_id, project_id, ' . $t_vars_string . ') VALUES ( ' . $t_params_string . ')'; db_query($t_query, $t_values); return true; }
public function printMultipleBalance() { $flash = Flash::Instance(); $errors = array(); $extra = array(); if (!isset($this->_data['WHLocation_location']) || empty($this->_data['WHLocation_location'])) { $errors[] = 'Location is a required field'; } if (!isset($this->_data['WHBin_bins']) || empty($this->_data['WHBin_bins'])) { $errors[] = 'Bin is a required field'; } if (count($errors) > 0) { $flash->addErrors($errors); sendBack(); } // Check and set default print set $userPreferences = UserPreferences::instance(EGS_USERNAME); $defaultPrinter = $userPreferences->getPreferenceValue('default_printer', 'shared'); if (empty($defaultPrinter)) { $flash->addError('Cannot print without a default printer set'); sendBack(); } else { $this->_data['printtype'] = 'pdf'; $this->_data['printaction'] = 'Print'; $this->_data['printer'] = $defaultPrinter; } // construct constraint against bins $stbalances = new STBalanceCollection(); $sh = new SearchHandler($stbalances, FALSE); $sh->addConstraint(new Constraint('balance', '<>', 0)); $sh->addConstraint(new Constraint('whstore_id', '=', $this->_data['WHStore_store'])); $sh->addConstraint(new Constraint('whlocation_id', '=', $this->_data['WHLocation_location'])); $binlist = implode(',', $this->_data['WHBin_bins']); $sh->addConstraint(new Constraint('whbin_id', 'in', '(' . $binlist . ')')); $sh->setOrderby(array('whbin', 'stitem'), array('ASC', 'ASC')); $stbalances->load($sh); // set title $WHLocation = $this->_templateobject; $WHLocation->load($this->_data['WHLocation_location']); $WHStore = DataObjectFactory::Factory('WHStore'); $WHStore->load($this->_data['WHStore_store']); $extra['title'] = 'Stock Balance for ' . $WHStore->description . ' / ' . $WHLocation->description . ' as at ' . un_fix_date(fix_date(date(DATE_FORMAT))); // construct xml $xml = $this->generateXML(array('model' => $stbalances, 'load_relationships' => FALSE, 'extra' => $extra)); // build a basic list of options $options = array('report' => 'MF_MultipleStockBalance', 'xmlSource' => $xml); // construct the document, caputre the response $response = json_decode($this->constructOutput($this->_data, $options)); // output success / failure message if ($response->status !== TRUE) { $flash->addError("Error printing document » " . $response->message); } else { $flash->addMessage("Document printed successfully"); } // return back to eglet sendBack(); }
function _opt_in($options, $platform, $opt_link) { $social = new Social(); $lang =& DoceboLanguage::createInstance('register', $platform); // Check for error $out = ''; $error = $this->_checkField($_POST, $options, $platform, true); if ($error['error']) { $this->error = true; return '<div class="reg_err_data">' . $error['msg'] . '</div>'; } // Insert temporary $random_code = md5($_POST['register']['userid'] . mt_rand() . mt_rand() . mt_rand()); // register as temporary user and send mail $acl_man =& Docebo::user()->getAclManager(); $iduser = $acl_man->registerTempUser($_POST['register']['userid'], $_POST['register']['firstname'], $_POST['register']['lastname'], $_POST['register']['pwd'], $_POST['register']['email'], $random_code); if ($iduser === false) { $out .= '<div class="reg_err_data">' . $lang->def('_OPERATION_FAILURE') . '</div>'; $this->error = true; return $out; } // facebook register: if ($social->isActive('facebook')) { if (isset($_SESSION['fb_info']) && is_array($_SESSION['fb_info'])) { $social = new Social(); $social->connectAccount('facebook', $_SESSION['fb_info']['id'], $iduser, true); unset($_SESSION['fb_info']); } } // ---- // add base inscription policy $enrollrules = new EnrollrulesAlms(); $enrollrules->newRules('_NEW_USER', array($iduser), Lang::get()); // subscribe to groups ----------------------------------------- if (isset($_POST['group_sel_implode'])) { $groups = explode(',', $_POST['group_sel_implode']); while (list(, $idst) = each($groups)) { $acl_man->addToGroup($idst, $iduser); // FORMA: added the inscription policy $enrollrules = new EnrollrulesAlms(); $enrollrules->applyRulesMultiLang('_LOG_USERS_TO_GROUP', array((string) $iduser), false, (int) $idst, true); // END FORMA } } //if the user had enter a code we must check if there are folder related to it and add the folder's field $registration_code_type = Get::sett('registration_code_type', '0'); $code_is_mandatory = Get::sett('mandatory_code', 'off') == 'on'; $reg_code = Get::req('reg_code', DOTY_MIXED, ''); if ($registration_code_type === 'custom') { $reg_code = 'change_by_custom_operation'; } $array_folder = false; $uma = new UsermanagementAdm(); $reg_code_res = $this->processRegistrationCode($acl_man, $uma, $iduser, $reg_code, $registration_code_type); if ($reg_code_res['success'] == false) { $acl_man->deleteTempUser($iduser); $this->error = true; return '<div class="reg_err_data">' . $reg_code_res['msg'] . '</div>'; } // save language selected require_once _base_ . '/lib/lib.preference.php'; $preference = new UserPreferences($iduser); $preference->setPreference('ui.language', Lang::get()); // Save fields $extra_field = new FieldList(); $extra_field->setFieldEntryTable($GLOBALS['prefix_fw'] . '_field_userentry'); $extra_field->storeFieldsForUser($iduser); // Send mail $admin_mail = $options['mail_sender']; // FIX BUG 399 //$link = str_replace('&', '&', $opt_link.( strpos($opt_link, '?') === false ? '?' : '&' ).'random_code='.$random_code); $link = Get::sett('url', '') . 'index.php?modname=login&op=register_opt&random_code=' . $random_code; // END FIX BUG 399 $text = $lang->def('_REG_MAIL_TEXT'); $text = str_replace('[userid]', $_POST['register']['userid'], $text); $text = str_replace('[firstname]', $_POST['register']['firstname'], $text); $text = str_replace('[lastname]', $_POST['register']['lastname'], $text); $text = str_replace('[password]', $_POST['register']['pwd'], $text); $text = str_replace('[link]', '' . $link . '', $text); $text = str_replace('[hour]', $options['hour_request_limit'], $text); $text = stripslashes($text); //check register_type != self (include all previous cases except the new one "self without opt-in") if (strcmp($options['register_type'], 'self') != 0) { require_once _base_ . '/lib/lib.mailer.php'; $mailer = DoceboMailer::getInstance(); if (!$mailer->SendMail($admin_mail, $_POST['register']['email'], Lang::t('_MAIL_OBJECT', 'register'), $text, false, array(MAIL_REPLYTO => $admin_mail, MAIL_SENDER_ACLNAME => false))) { if ($registration_code_type == 'code_module') { // ok, the registration has failed, let's remove the user association form the code $code_manager = new CodeManager(); $code_manager->resetUserAssociation($code, $iduser); } $acl_man->deleteTempUser($iduser); $this->error = true; $out .= '<div class="reg_err_data">' . $lang->def('_OPERATION_FAILURE') . '</div>'; } else { $out .= '<div class="reg_success">' . $lang->def('_REG_SUCCESS') . '</div>'; } } //end $_GET['random_code'] = $random_code; $_GET['idst'] = $iduser; //check register_type = self if (strcmp($options['register_type'], 'self') == 0) { $text_self = $lang->def('_REG_MAIL_TEXT_SELF'); $text_self = str_replace('[userid]', $_POST['register']['userid'], $text_self); $text_self = str_replace('[firstname]', $_POST['register']['firstname'], $text_self); $text_self = str_replace('[lastname]', $_POST['register']['lastname'], $text_self); $text_self = str_replace('[password]', $_POST['register']['pwd'], $text_self); require_once _base_ . '/lib/lib.mailer.php'; $mailer = DoceboMailer::getInstance(); if (!$mailer->SendMail($admin_mail, $_POST['register']['email'], Lang::t('_MAIL_OBJECT_SELF', 'register'), $text_self, false, false)) { $out .= '<div class="reg_err_data">' . $lang->def('_OPERATION_FAILURE') . '</div>'; } else { $this->confirmRegister($this->_platform, $options); $out .= '<div class="reg_success">' . $lang->def('_REG_SUCCESS_SELF') . '</div>'; } } //end return $out; }
/** * perform an insert of a preference object into the DB * @param int $p_user_id * @param int $p_project_id * @param UserPreferences $p_prefs * @return true */ function user_pref_insert( $p_user_id, $p_project_id, $p_prefs ) { static $t_vars; $c_user_id = db_prepare_int( $p_user_id ); $c_project_id = db_prepare_int( $p_project_id ); user_ensure_unprotected( $p_user_id ); $t_user_pref_table = db_get_table( 'user_pref' ); if ($t_vars == null ) { $t_vars = getClassProperties( 'UserPreferences', 'protected'); } $t_values = array(); $t_params[] = db_param(); // user_id $t_values[] = $c_user_id; $t_params[] = db_param(); // project_id $t_values[] = $c_project_id; foreach( $t_vars as $var => $val ) { array_push( $t_params, db_param()); array_push( $t_values, $p_prefs->Get( $var ) ); } $t_vars_string = implode( ', ', array_keys( $t_vars ) ); $t_params_string = implode( ',', $t_params ); $query = 'INSERT INTO ' . $t_user_pref_table . ' (user_id, project_id, ' . $t_vars_string . ') ' . ' VALUES ( ' . $t_params_string . ')'; db_query_bound( $query, $t_values ); # db_query errors on failure so: return true; }
function org_waitingUser() { checkPerm('approve_waiting_user', false, 'directory', 'framework'); require_once _base_ . '/lib/lib.form.php'; require_once $GLOBALS['where_framework'] . '/lib/lib.field.php'; require_once _base_ . '/lib/lib.table.php'; require_once _base_ . '/lib/lib.usermanager.php'; if (isset($_POST['ok_waiting'])) { $user_man = new UserManager(); // Remove refused users $refused = array(); $aopproved = array(); if (isset($_POST['waiting_user_refuse'])) { while (list($idst) = each($_POST['waiting_user_refuse'])) { $this->aclManager->deleteTempUser($idst, false, false, true); } $refused[] = $idst; } // Subscribed accepted users if (isset($_POST['waiting_user_accept'])) { $idst_usergroup = $this->aclManager->getGroup(false, ADMIN_GROUP_USER); $idst_usergroup = $idst_usergroup[ACL_INFO_IDST]; $idst_oc = $this->aclManager->getGroup(false, '/oc_0'); $idst_oc = $idst_oc[ACL_INFO_IDST]; $idst_ocd = $this->aclManager->getGroup(false, '/ocd_0'); $idst_ocd = $idst_ocd[ACL_INFO_IDST]; $request = $this->aclManager->getTempUsers(false, true); while (list($idst) = each($_POST['waiting_user_accept'])) { if ($this->aclManager->registerUser(addslashes($request[$idst]['userid']), addslashes($request[$idst]['firstname']), addslashes($request[$idst]['lastname']), $request[$idst]['pass'], addslashes($request[$idst]['email']), '', '', true, $idst)) { $approved[] = $idst; $this->aclManager->addToGroup($idst_usergroup, $idst); $this->aclManager->addToGroup($idst_oc, $idst); $this->aclManager->addToGroup($idst_ocd, $idst); if ($request[$idst]['create_by_admin'] != 0) { $pref = new UserPreferences($request[$idst]['create_by_admin']); if ($pref->getAdminPreference('admin_rules.limit_user_insert') == 'on') { $max_insert = $pref->getAdminPreference('admin_rules.max_user_insert'); $pref->setPreference('admin_rules.max_user_insert', $max_insert - 1); } } $this->aclManager->deleteTempUser($idst, false, false, false); } } } require_once _base_ . '/lib/lib.platform.php'; require_once _base_ . '/lib/lib.eventmanager.php'; // send the alert /* if(!empty($refused)) { $array_subst = array('[url]' => Get::sett('url')); $msg_composer = new EventMessageComposer('admin_directory', 'framework'); $msg_composer->setSubjectLangText('email', '_REFUSED_USER_SBJ', false); $msg_composer->setBodyLangText('email', '_REFUSED_USER_TEXT', $array_subst); $msg_composer->setBodyLangText('sms', '_REFUSED_USER_TEXT_SMS', $array_subst); createNewAlert( 'UserApproved', 'directory', 'edit', '1', 'Users refused', $refused, $msg_composer ); }*/ if (!empty($approved)) { $pl_man =& PlatformManager::createInstance(); $array_subst = array('[url]' => Get::sett('url', '')); $msg_composer2 = new EventMessageComposer('admin_directory', 'framework'); $msg_composer2->setSubjectLangText('email', '_APPROVED_USER_SBJ', false); $msg_composer2->setBodyLangText('email', '_APPROVED_USER_TEXT', $array_subst); $msg_composer2->setBodyLangText('sms', '_APPROVED_USER_TEXT_SMS', $array_subst); createNewAlert('UserApproved', 'directory', 'edit', '1', 'Users approved', $approved, $msg_composer2, true); } Util::jump_to('index.php?modname=directory&op=org_chart'); } elseif (isset($_POST['cancel_waiting'])) { Util::jump_to('index.php?modname=directory&op=org_chart'); } else { $tb = new Table(0, $this->lang->def('_WAITING_USERS'), $this->lang->def('_WAITING_USER_SUMMARY')); $type_h = array('', '', '', 'image', 'image'); $cont_h = array($this->lang->def('_USERNAME'), $this->lang->def('_DIRECTORY_FULLNAME'), $this->lang->def('_BY'), '<img src="' . getPathImage('framework') . 'directory/wuser_accept.gif" alt="' . $this->lang->def('_ACCEPT') . '" ' . 'title="' . $this->lang->def('_ACCEPT_USER') . '" />', '<img src="' . getPathImage('framework') . 'directory/wuser_refuse.gif" alt="' . $this->lang->def('_REFUSE_USER') . '" ' . 'title="' . $this->lang->def('_REFUSE_USER_TITLE') . '" />'); $tb->setColsStyle($type_h); $tb->addHead($cont_h); $temp_users = $this->aclManager->getTempUsers(false, true); if ($temp_users !== false) { $idst_admins = array(); while (list($idst, $info) = each($temp_users)) { if ($info['create_by_admin'] != 0) { $idst_admins[] = $info['create_by_admin']; } } $admins = $this->aclManager->getUsers($idst_admins); reset($temp_users); while (list($idst, $info) = each($temp_users)) { if ($info['create_by_admin'] != 0) { $creator = $admins[$info['create_by_admin']][ACL_INFO_LASTNAME] . ' ' . $admins[$info['create_by_admin']][ACL_INFO_FIRSTNAME]; if ($creator == '') { $creator = $this->aclManager->relativeId($admins[$info['create_by_admin']][ACL_INFO_USERID]); } } else { $creator = $this->lang->def('_DIRECOTRY_SELFREGISTERED'); } $more = isset($_GET['id_user']) && $_GET['id_user'] == $idst ? '<a href="index.php?modname=directory&op=org_waitinguser"><img src="' . getPathImage() . 'standard/less.gif"></a> ' : '<a href="index.php?modname=directory&op=org_waitinguser&id_user='******'"><img src="' . getPathImage() . 'standard/more.gif"></a> '; $cont = array($more . $this->aclManager->relativeId($info['userid']), $info['lastname'] . ' ' . $info['firstname'], $creator, Form::getInputCheckbox('waiting_user_accept_' . $idst, 'waiting_user_accept[' . $idst . ']', $idst, false, '') . Form::getLabel('waiting_user_accept_' . $idst, $this->lang->def('_ACCEPT'), 'access-only'), Form::getInputCheckbox('waiting_user_refuse_' . $idst, 'waiting_user_refuse[' . $idst . ']', $idst, false, '') . Form::getLabel('waiting_user_refuse_' . $idst, $this->lang->def('_REFUSE_USER'), 'access-only')); $tb->addBody($cont); if (isset($_GET['id_user']) && $idst == $_GET['id_user']) { $field = new FieldList(); $tb->addBodyExpanded($field->playFieldsForUser($idst, false, true), 'user_specific_info'); } } } $GLOBALS['page']->add(getTitleArea($this->lang->def('_WAITING_USERS'), 'directory') . '<div class="std_block">' . Form::openForm('waiting_user', 'index.php?modname=directory&op=org_waitinguser') . $tb->getTable() . Form::openButtonSpace() . Form::getButton('ok_waiting', 'ok_waiting', $this->lang->def('_SAVE')) . Form::getButton('cancel_waiting', 'cancel_waiting', $this->lang->def('_UNDO')) . Form::closeButtonSpace() . Form::closeForm() . '</div>', 'content'); } }