Example #1
0
 public function checkPassword()
 {
     $newPassword = $this->processor->getProperty('newpassword', null);
     $id = $this->processor->getProperty('id');
     if ($newPassword !== null && $newPassword != 'false' || empty($id)) {
         $passwordNotifyMethod = $this->processor->getProperty('passwordnotifymethod', null);
         if (empty($passwordNotifyMethod)) {
             $this->processor->addFieldError('password_notify_method', $this->modx->lexicon('user_err_not_specified_notification_method'));
         }
         $passwordGenerationMethod = $this->processor->getProperty('passwordgenmethod', 'g');
         if ($passwordGenerationMethod == 'g') {
             $len = $this->modx->getOption('password_generated_length', null, 8);
             $autoPassword = $this->generatePassword($len);
             $this->user->set('password', $autoPassword);
             $this->processor->newPassword = $autoPassword;
         } else {
             $specifiedPassword = $this->processor->getProperty('specifiedpassword');
             $confirmPassword = $this->processor->getProperty('confirmpassword');
             if (empty($specifiedPassword)) {
                 $this->processor->addFieldError('specifiedpassword', $this->modx->lexicon('user_err_not_specified_password'));
             } elseif ($specifiedPassword != $confirmPassword) {
                 $this->processor->addFieldError('confirmpassword', $this->modx->lexicon('user_err_password_no_match'));
             } elseif (strlen($specifiedPassword) < $this->modx->getOption('password_min_length', null, 6)) {
                 $this->processor->addFieldError('specifiedpassword', $this->modx->lexicon('user_err_password_too_short'));
             } elseif (!preg_match('/^[^\'\\x3c\\x3e\\(\\);\\x22]+$/', $specifiedPassword)) {
                 $this->processor->addFieldError('specifiedpassword', $this->modx->lexicon('user_err_password_invalid'));
             } else {
                 $this->user->set('password', $specifiedPassword);
                 $this->processor->newPassword = $specifiedPassword;
             }
         }
     }
     return $this->processor->newPassword;
 }
Example #2
0
 public function process()
 {
     if (!$this->addLock()) {
         return $this->failure($this->modx->lexicon('resource_locked_by', array('id' => $this->resource->get('id'), 'user' => $this->lockedUser->get('username'))));
     }
     /* 'undelete' the resource. */
     $this->resource->set('deleted', false);
     $this->resource->set('deletedby', 0);
     $this->resource->set('deletedon', 0);
     if ($this->resource->save() == false) {
         $this->resource->removeLock();
         return $this->failure($this->modx->lexicon('resource_err_undelete'));
     }
     $this->unDeleteChildren($this->resource->get('id'), $this->resource->get('deletedon'));
     $this->fireAfterUnDeleteEvent();
     /* log manager action */
     $this->logManagerAction();
     /* empty cache */
     $skipClearCache = $this->getProperty('skipClearCache', false);
     if ($skipClearCache == false) {
         $this->clearCache();
     }
     $this->removeLock();
     $deletedCount = $this->modx->getCount('modResource', array('deleted' => 1));
     $outputArray = $this->resource->get(array('id'));
     $outputArray['deletedCount'] = $deletedCount;
     return $this->modx->error->success('', $outputArray);
 }
Example #3
0
 /**
  * {@inheritDoc}
  * @return mixed
  */
 public function process()
 {
     if ($this->modx->getOption('site_start') == $this->resource->get('id')) {
         return $this->failure($this->modx->lexicon('resource_err_delete_sitestart'));
     }
     if ($this->modx->getOption('site_unavailable_page') == $this->resource->get('id')) {
         return $this->failure($this->modx->lexicon('resource_err_delete_siteunavailable'));
     }
     /* check for locks on resource */
     if (!$this->addLock()) {
         return $this->failure($this->modx->lexicon('resource_locked_by', array('id' => $this->resource->get('id'), 'user' => $this->lockedUser->get('username'))));
     }
     $childrenIds = $this->getChildrenIds();
     $this->fireBeforeDelete($childrenIds);
     /* delete children */
     $this->deleteChildren();
     /* delete the document. */
     $this->resource->set('deleted', true);
     $this->resource->set('deletedby', $this->modx->user->get('id'));
     $this->resource->set('deletedon', $this->deletedTime);
     if ($this->resource->save() == false) {
         $this->resource->removeLock();
         return $this->failure($this->modx->lexicon('resource_err_delete'));
     }
     $this->fireAfterDelete($childrenIds);
     /* log manager action */
     $this->logManagerAction();
     $this->resource->removeLock();
     /* empty cache */
     $this->clearCache();
     return $this->success('', $this->resource->get(array('id', 'deleted', 'deletedby', 'deletedon')));
 }
Example #4
0
 public function process()
 {
     if (!$this->addLock()) {
         return $this->failure($this->modx->lexicon('resource_locked_by', array('id' => $this->resource->get('id'), 'user' => $this->lockedUser->get('username'))));
     }
     if ($this->isSiteStart()) {
         return $this->failure($this->modx->lexicon('resource_err_unpublish_sitestart'));
     }
     $this->resource->set('published', false);
     $this->resource->set('pub_date', false);
     $this->resource->set('unpub_date', false);
     $this->resource->set('editedby', $this->modx->user->get('id'));
     $this->resource->set('editedon', time(), 'integer');
     $this->resource->set('publishedby', false);
     $this->resource->set('publishedon', false);
     if ($this->resource->save() == false) {
         $this->resource->removeLock();
         return $this->failure($this->modx->lexicon('resource_err_unpublish'));
     }
     $this->fireAfterUnPublishEvent();
     $this->logManagerAction();
     $skipClearCache = $this->getProperty('skipClearCache', false);
     if ($skipClearCache == false) {
         $this->clearCache();
     }
     return $this->success('', $this->resource->get(array('id')));
 }
Example #5
0
 public function process()
 {
     if (!$this->addLock()) {
         return $this->failure($this->modx->lexicon('resource_locked_by', array('id' => $this->resource->get('id'), 'user' => $this->lockedUser->get('username'))));
     }
     $duplicateAlias = $this->checkForDuplicateAlias();
     if ($duplicateAlias !== false) {
         return $this->failure($duplicateAlias);
     }
     /* publish resource */
     $this->resource->set('published', true);
     $this->resource->set('pub_date', false);
     $this->resource->set('unpub_date', false);
     $this->resource->set('editedby', $this->modx->user->get('id'));
     $this->resource->set('editedon', time(), 'integer');
     $this->resource->set('publishedby', $this->modx->user->get('id'));
     $this->resource->set('publishedon', time());
     $saved = $this->resource->save();
     $this->resource->removeLock();
     if (!$saved) {
         return $this->failure($this->modx->lexicon('resource_err_publish'));
     }
     $this->fireAfterPublish();
     $this->logManagerAction();
     $this->clearCache();
     return $this->success('', $this->resource->get(array('id', 'pub_date', 'unpub_date', 'editedby', 'editedon', 'publishedby', 'publishedon')));
 }
 public function setUp()
 {
     parent::setUp();
     $this->controller = $this->login->loadController('Register');
     $this->user = $this->modx->newObject('modUser');
     $this->user->fromArray(array('id' => 12345678, 'username' => 'unit.test.user', 'password' => md5('a test password'), 'cachepwd' => '', 'class_key' => 'modUser', 'active' => false, 'hash_class' => 'hashing.modMD5', 'salt' => '', 'primary_group' => 1));
     $_POST = array('username' => 'unit.test.user', 'password' => 'a test password', 'password_confirm' => 'a test password', 'email' => LoginTestHarness::$properties['email'], 'nospam' => '', 'submitVar' => 'unit-test-register-btn');
     $this->controller->setProperties(array('activation' => true, 'activationResourceId' => 1, 'activationEmailSubject' => 'Login Unit Test Activation Email', 'moderatedResourceId' => 1, 'preHooks' => '', 'postHooks' => '', 'submitVar' => 'unit-test-register-btn', 'submittedResourceId' => 1, 'usergroups' => '', 'validate' => 'nospam:blank'));
     $this->controller->loadDictionary();
 }
Example #7
0
 /**
  * See if the user is the last member in the administrators group
  * @return boolean
  */
 public function isLastUserInAdministrators()
 {
     $last = false;
     /** @var modUserGroup $group */
     $group = $this->modx->getObject('modUserGroup', array('name' => 'Administrator'));
     if ($group && $this->object->isMember('Administrator')) {
         $numberInAdminGroup = $this->modx->getCount('modUserGroupMember', array('user_group' => $group->get('id')));
         if ($numberInAdminGroup <= 1) {
             $last = true;
         }
     }
     return $last;
 }
Example #8
0
 /**
  * {@inheritDoc}
  * @return boolean|string
  */
 public function beforeSet()
 {
     $locked = $this->addLock();
     if ($locked !== true) {
         if ($this->lockedUser) {
             return $this->failure($this->modx->lexicon('resource_locked_by', array('id' => $this->object->get('id'), 'user' => $this->lockedUser->get('username'))));
         } else {
             return $this->failure($this->modx->lexicon('access_denied'));
         }
     }
     /* RTE workaround */
     $properties = $this->getProperties();
     if (isset($properties['ta'])) {
         $this->setProperty('content', $properties['ta']);
     }
     $this->workingContext = $this->modx->getContext($this->getProperty('context_key'));
     $this->trimPageTitle();
     $this->handleParent();
     $this->checkParentContext();
     $this->handleCheckBoxes();
     $this->checkFriendlyAlias();
     $this->setPublishDate();
     $this->setUnPublishDate();
     $this->checkPublishedOn();
     $this->checkPublishingPermissions();
     $this->checkForUnPublishOnSiteStart();
     $this->checkDeletedStatus();
     $this->handleResourceProperties();
     $this->unsetProperty('variablesmodified');
     return parent::beforeSet();
 }
Example #9
0
 /**
  * If wanting to redirect after confirmed registration (for shopping carts)
  * Also allow &redirectBack parameter sent in confirmation email to redirect
  * to a form requiring registration
  */
 public function redirectBack()
 {
     $redirectBack = $this->modx->getOption('redirectBack', $_REQUEST, $this->getProperty('redirectBack', false, 'isset'));
     $redirectBackParams = $this->modx->getOption('redirectBackParams', $_REQUEST, $this->getProperty('redirectBackParams', ''));
     if (!empty($redirectBackParams)) {
         $redirectBackParams = $this->login->decodeParams($redirectBackParams);
     }
     $redirectTo = $this->getProperty('redirectTo', $redirectBack);
     if (!empty($redirectTo)) {
         /* allow custom redirection params */
         $redirectParams = $this->getProperty('redirectParams', $redirectBackParams);
         if (!empty($redirectParams) && !is_array($redirectParams)) {
             $redirectParams = $this->modx->fromJSON($redirectParams);
         }
         if (empty($redirectParams) || !is_array($redirectParams)) {
             $redirectParams = array();
         }
         /* handle persist params from Register snippet */
         $redirectUnsetDefaultParams = (bool) $this->getProperty('redirectUnsetDefaultParams', 0, 'isset');
         if (!$redirectUnsetDefaultParams) {
             $persistParams = $_GET;
             unset($persistParams['lp'], $persistParams['lu'], $persistParams['id']);
             $persistParams['username'] = $this->user->get('username');
             $persistParams['userid'] = $this->user->get('id');
             $redirectParams = array_merge($redirectParams, $persistParams);
             unset($redirectParams[$this->modx->getOption('request_param_alias', null, 'q')], $redirectParams['redirectBack']);
         }
         /* redirect user */
         $url = $this->modx->makeUrl($redirectTo, '', $redirectParams, 'full');
         $this->modx->sendRedirect($url);
     }
 }
Example #10
0
 /**
  * Fetch the user to update, also allowing external user updating
  * @return modUser
  */
 public function fetchUser()
 {
     $fields = $this->dictionary->toArray();
     $this->usernameField = 'username';
     $alias = 'modUser';
     if (empty($fields['username']) && !empty($fields['email'])) {
         $this->usernameField = 'email';
         $alias = 'Profile';
     }
     /* if the preHook didn't set the user info, find it by email/username */
     if (empty($fields[Login::FORGOT_PASSWORD_EXTERNAL_USER])) {
         /* get the user dependent on the retrieval method */
         $this->user = $this->login->getUserByField($this->usernameField, $fields[$this->usernameField], $alias);
         if ($this->user) {
             $fields = array_merge($fields, $this->user->toArray());
             $this->profile = $this->user->getOne('Profile');
             if ($this->profile) {
                 /* merge in profile */
                 $fields = array_merge($this->profile->toArray(), $fields);
             }
         }
     }
     $this->dictionary->fromArray($fields);
     return $this->user;
 }
Example #11
0
 /** Actions after user is logged in
  *
  * @return array
  */
 public function afterLogin()
 {
     $this->addSessionContexts();
     $this->fireAfterLoginEvent();
     $this->modx->logManagerAction('login', 'modContext', $this->loginContext, $this->user->get('id'));
     return $this->prepareResponse();
 }
Example #12
0
 /**
  * Return the pagetitle
  *
  * @return string
  */
 public function getPageTitle()
 {
     if ($this->user == null) {
         return $this->modx->lexicon('user_err_nf');
     } else {
         return $this->modx->lexicon('user') . ': ' . $this->user->get('username');
     }
 }
 /**
  * Get the profile for the user
  * 
  * @return bool|modUserProfile
  */
 public function getProfile()
 {
     $this->profile = $this->user->getOne('Profile');
     if (empty($this->profile)) {
         $this->modx->log(modX::LOG_LEVEL_ERROR, 'Could not find profile for user: '******'username'));
         return false;
     }
     return $this->profile;
 }
Example #14
0
 /**
  * Send the password notification email, if specified
  * @return void
  */
 public function sendNotificationEmail()
 {
     if ($this->getProperty('passwordnotifymethod') == 'e') {
         $message = $this->modx->getOption('signupemail_message');
         $placeholders = array('uid' => $this->object->get('username'), 'pwd' => $this->newPassword, 'ufn' => $this->profile->get('fullname'), 'sname' => $this->modx->getOption('site_name'), 'saddr' => $this->modx->getOption('emailsender'), 'semail' => $this->modx->getOption('emailsender'), 'surl' => $this->modx->getOption('url_scheme') . $this->modx->getOption('http_host') . $this->modx->getOption('manager_url'));
         foreach ($placeholders as $k => $v) {
             $message = str_replace('[[+' . $k . ']]', $v, $message);
         }
         $this->object->sendEmail($message);
     }
 }
Example #15
0
 /**
  * If allow_multiple_emails setting is false, prevent duplicate emails
  * @return void
  */
 public function preventDuplicateEmails()
 {
     $emailField = $this->getProperty('emailField', 'email');
     $email = $this->dictionary->get($emailField);
     if (!empty($email) && !$this->modx->getOption('allow_multiple_emails', null, false)) {
         $emailTaken = $this->modx->getObject('modUserProfile', array('email' => $email, 'internalKey:!=' => $this->user->get('id')));
         if ($emailTaken) {
             $this->validator->addError($emailField, $this->modx->lexicon('login.email_taken', array('email' => $email)));
         }
     }
 }
Example #16
0
 /**
  * Get the User Groups for the user
  * @return array
  */
 public function getUserGroups()
 {
     $c = $this->modx->newQuery('modUserGroupMember');
     $c->leftJoin('modUserGroupRole', 'UserGroupRole');
     $c->innerJoin('modUserGroup', 'UserGroup');
     $c->where(array('member' => $this->user->get('id')));
     $c->select($this->modx->getSelectColumns('modUserGroupMember', 'modUserGroupMember'));
     $c->select(array('role_name' => 'UserGroupRole.name', 'user_group_name' => 'UserGroup.name'));
     $members = $this->modx->getCollection('modUserGroupMember', $c);
     $data = array();
     /** @var modUserGroupMember $member */
     foreach ($members as $member) {
         $roleName = $member->get('role_name');
         if ($member->get('role') == 0) {
             $roleName = $this->modx->lexicon('none');
         }
         $data[] = array($member->get('user_group'), $member->get('user_group_name'), $member->get('member'), $member->get('role'), empty($roleName) ? '' : $roleName);
     }
     $this->user->set('groups', '(' . $this->modx->toJSON($data) . ')');
     return $data;
 }
Example #17
0
 public function getOne($class, $criteria = null)
 {
     if ($criteria === null && $class === 'modActiveUser') {
         if ($userid = $this->get('id')) {
             $userid = $userid * -1;
             $activeUserTable = $this->xpdo->getTableName('modActiveUser');
             $sql = "SELECT * FROM {$activeUserTable} WHERE `id` = :user_id LIMIT 1";
             $bindings = array(':user_id' => array('value' => $userid, 'type' => PDO::PARAM_INT));
             $criteria = new xPDOCriteria($this->xpdo, $sql, $bindings, true);
         }
     }
     return parent::getOne($class, $criteria);
 }
 public function setUp()
 {
     parent::setUp();
     $this->user = $this->modx->newObject('modUser');
     $this->user->fromArray(array('id' => 12345678, 'username' => 'unit.test.user', 'password' => md5('a test password'), 'cachepwd' => '', 'class_key' => 'modUser', 'active' => false, 'hash_class' => 'hashing.modMD5', 'salt' => '', 'primary_group' => 1, 'email' => LoginTestHarness::$properties['email']));
     $this->profile = $this->modx->newObject('modUserProfile');
     $this->profile->fromArray(array('internalKey' => 12345678, 'email' => LoginTestHarness::$properties['email'], 'blocked' => false));
     /** @var modUserGroup $userGroup */
     $userGroup = $this->modx->newObject('modUserGroup');
     $userGroup->fromArray(array('name' => 'UnitTest UserGroup 1'));
     $userGroup->save();
     $userGroup = $this->modx->newObject('modUserGroup');
     $userGroup->fromArray(array('name' => 'UnitTest UserGroup 2'));
     $userGroup->save();
     $_POST = array('username' => 'unit.test.user', 'password' => 'a test password', 'email' => '*****@*****.**', 'nospam' => '', 'submitVar' => 'unit-test-register-btn');
     $this->controller = $this->login->loadController('Register');
     $this->controller->initialize();
     $this->controller->setProperties(array('activation' => true, 'activationResourceId' => 1, 'activationEmailSubject' => 'Login Unit Test Activation Email', 'moderatedResourceId' => 1, 'preHooks' => '', 'postHooks' => '', 'submitVar' => 'unit-test-register-btn', 'submittedResourceId' => 1, 'usergroups' => '', 'validate' => 'nospam:blank'));
     $this->controller->loadDictionary();
     $this->processor = $this->controller->loadProcessor('Register');
     $this->processor->user =& $this->user;
     $this->processor->profile =& $this->profile;
 }
 /**
  * Check for a redirect if the user was successfully registered. If one found, redirect.
  *
  * @return boolean
  */
 public function checkForRegisteredRedirect()
 {
     /* if provided a redirect id, will redirect to that resource, with the
      * GET params `username` and `email` for you to use */
     $submittedResourceId = $this->controller->getProperty('submittedResourceId', '');
     if (!empty($submittedResourceId)) {
         $persistParams = array_merge($this->persistParams, array('username' => $this->user->get('username'), 'email' => $this->profile->get('email')));
         $url = $this->modx->makeUrl($submittedResourceId, '', $persistParams, 'full');
         if (!$this->login->inTestMode) {
             $this->modx->sendRedirect($url);
         }
         return true;
     }
     return false;
 }
Example #20
0
 /**
  * Return the response chunk
  * @return string
  */
 public function getResponse()
 {
     $placeholders = array('username' => $this->user->get('username'), 'loginUrl' => $this->modx->makeUrl($this->getProperty('loginResourceId', 1)));
     return $this->login->getChunk($this->getProperty('tpl'), $placeholders, $this->getProperty('tplType', 'modChunk'));
 }
Example #21
0
 function __construct(xPDO &$xpdo)
 {
     parent::__construct($xpdo);
     $this->set('class_key', 'idfxUser');
 }
Example #22
0
/**
 * Disable/Reenable features modules.
 * We must do this when internal menu of module or permissions has changed
 * or when triggers have moved.
 *
 * @param	DoliDB		$db				Database handler
 * @param	Translate	$langs			Object langs
 * @param	Conf		$conf			Object conf
 * @param	array		$listofmodule	List of modules
 * @return	void
 */
function migrate_reload_modules($db, $langs, $conf, $listofmodule = array())
{
    dolibarr_install_syslog("upgrade2::migrate_reload_modules");
    // If no info is provided, we reload all modules with mode newboxdefonly.
    if (count($listofmodule) == 0) {
        $listofmodule = array('MAIN_MODULE_AGENDA' => 'newboxdefonly', 'MAIN_MODULE_SOCIETE' => 'newboxdefonly', 'MAIN_MODULE_PRODUIT' => 'newboxdefonly', 'MAIN_MODULE_SERVICE' => 'newboxdefonly', 'MAIN_MODULE_COMMANDE' => 'newboxdefonly', 'MAIN_MODULE_FACTURE' => 'newboxdefonly', 'MAIN_MODULE_FOURNISSEUR' => 'newboxdefonly', 'MAIN_MODULE_HOLIDAY' => 'newboxdefonly', 'MAIN_MODULE_USER' => 'newboxdefonly', 'MAIN_MODULE_DEPLACEMENT' => 'newboxdefonly', 'MAIN_MODULE_DON' => 'newboxdefonly', 'MAIN_MODULE_ECM' => 'newboxdefonly', 'MAIN_MODULE_PAYBOX' => 'newboxdefonly', 'MAIN_MODULE_OPENSURVEY' => 'newboxdefonly');
    }
    foreach ($listofmodule as $moduletoreload => $reloadmode) {
        if (empty($moduletoreload) || empty($conf->global->{$moduletoreload})) {
            continue;
        }
        $mod = null;
        if ($moduletoreload == 'MAIN_MODULE_AGENDA') {
            dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Agenda module");
            $res = @(include_once DOL_DOCUMENT_ROOT . '/core/modules/modAgenda.class.php');
            if ($res) {
                $mod = new modAgenda($db);
                $mod->remove('noboxes');
                $mod->init($reloadmode);
            }
        }
        if ($moduletoreload == 'MAIN_MODULE_BARCODE') {
            dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Barcode module");
            $res = @(include_once DOL_DOCUMENT_ROOT . '/core/modules/modBarcode.class.php');
            if ($res) {
                $mod = new modBarcode($db);
                $mod->remove('noboxes');
                $mod->init($reloadmode);
            }
        }
        if ($moduletoreload == 'MAIN_MODULE_CRON') {
            dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Cron module");
            $res = @(include_once DOL_DOCUMENT_ROOT . '/core/modules/modCron.class.php');
            if ($res) {
                $mod = new modCron($db);
                $mod->remove('noboxes');
                $mod->init($reloadmode);
            }
        }
        if ($moduletoreload == 'MAIN_MODULE_SOCIETE') {
            dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Societe module");
            $res = @(include_once DOL_DOCUMENT_ROOT . '/core/modules/modSociete.class.php');
            if ($res) {
                $mod = new modSociete($db);
                $mod->remove('noboxes');
                $mod->init($reloadmode);
            }
        }
        if ($moduletoreload == 'MAIN_MODULE_PRODUIT') {
            dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Produit module");
            $res = @(include_once DOL_DOCUMENT_ROOT . '/core/modules/modProduct.class.php');
            if ($res) {
                $mod = new modProduct($db);
                //$mod->remove('noboxes');
                $mod->init($reloadmode);
            }
        }
        if ($moduletoreload == 'MAIN_MODULE_SERVICE') {
            dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Service module");
            $res = @(include_once DOL_DOCUMENT_ROOT . '/core/modules/modService.class.php');
            if ($res) {
                $mod = new modService($db);
                //$mod->remove('noboxes');
                $mod->init($reloadmode);
            }
        }
        if ($moduletoreload == 'MAIN_MODULE_COMMANDE') {
            dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Commande module");
            $res = @(include_once DOL_DOCUMENT_ROOT . '/core/modules/modCommande.class.php');
            if ($res) {
                $mod = new modCommande($db);
                //$mod->remove('noboxes');
                $mod->init($reloadmode);
            }
        }
        if ($moduletoreload == 'MAIN_MODULE_FACTURE') {
            dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Facture module");
            $res = @(include_once DOL_DOCUMENT_ROOT . '/core/modules/modFacture.class.php');
            if ($res) {
                $mod = new modFacture($db);
                //$mod->remove('noboxes');
                $mod->init($reloadmode);
            }
        }
        if ($moduletoreload == 'MAIN_MODULE_FOURNISSEUR') {
            dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Fournisseur module");
            $res = @(include_once DOL_DOCUMENT_ROOT . '/core/modules/modFournisseur.class.php');
            if ($res) {
                $mod = new modFournisseur($db);
                //$mod->remove('noboxes');
                $mod->init($reloadmode);
            }
        }
        if ($moduletoreload == 'MAIN_MODULE_HOLIDAY') {
            dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Leave Request module");
            $res = @(include_once DOL_DOCUMENT_ROOT . '/core/modules/modHoliday.class.php');
            if ($res) {
                $mod = new modHoliday($db);
                $mod->remove('noboxes');
                $mod->init($reloadmode);
            }
        }
        if ($moduletoreload == 'MAIN_MODULE_DEPLACEMENT') {
            dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Deplacement module");
            $res = @(include_once DOL_DOCUMENT_ROOT . '/core/modules/modDeplacement.class.php');
            if ($res) {
                $mod = new modDeplacement($db);
                //$mod->remove('noboxes');
                $mod->init($reloadmode);
            }
        }
        if ($moduletoreload == 'MAIN_MODULE_DON') {
            dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Don module");
            $res = @(include_once DOL_DOCUMENT_ROOT . '/core/modules/modDon.class.php');
            if ($res) {
                $mod = new modDon($db);
                //$mod->remove('noboxes');
                $mod->init($reloadmode);
            }
        }
        if ($moduletoreload == 'MAIN_MODULE_ECM') {
            dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate ECM module");
            $res = @(include_once DOL_DOCUMENT_ROOT . '/core/modules/modECM.class.php');
            if ($res) {
                $mod = new modECM($db);
                $mod->remove('noboxes');
                // We need to remove because a permission id has been removed
                $mod->init($reloadmode);
            }
        }
        if ($moduletoreload == 'MAIN_MODULE_PAYBOX') {
            dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Paybox module");
            $res = @(include_once DOL_DOCUMENT_ROOT . '/core/modules/modPaybox.class.php');
            if ($res) {
                $mod = new modPaybox($db);
                $mod->remove('noboxes');
                // We need to remove because id of module has changed
                $mod->init($reloadmode);
            }
        }
        if ($moduletoreload == 'MAIN_MODULE_OPENSURVEY') {
            dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Opensurvey module");
            $res = @(include_once DOL_DOCUMENT_ROOT . '/core/modules/modOpenSurvey.class.php');
            if ($res) {
                $mod = new modOpenSurvey($db);
                $mod->remove('noboxes');
                // We need to remove because menu entries has changed
                $mod->init($reloadmode);
            }
        }
        if ($moduletoreload == 'MAIN_MODULE_USER') {
            dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate User module");
            $res = @(include_once DOL_DOCUMENT_ROOT . '/core/modules/modUser.class.php');
            if ($res) {
                $mod = new modUser($db);
                //$mod->remove('noboxes');
                $mod->init($reloadmode);
            }
        }
        if (!empty($mod) && is_object($mod)) {
            print '<tr><td colspan="4">';
            print '<b>' . $langs->trans('Upgrade') . '</b>: ';
            print $langs->trans('MigrationReloadModule') . " " . $mod->getName();
            print "<!-- (" . $reloadmode . ") -->";
            print "<br>\n";
            print '</td></tr>';
        }
    }
}
Example #23
0
 /**
  * Cache user data
  *
  * @param modUser $user User object
  *
  * @return bool
  */
 public function cacheUser(modUser &$user)
 {
     $cache = $this->modx->getCacheManager();
     if ($this->mtCache && $cache) {
         $profile = $user->getOne('Profile');
         $tmp = array('id' => $user->id, 'username' => $user->username, 'email' => $profile->email, 'fullname' => $profile->fullname);
         if (!$this->modx->cacheManager->set($user->id, $tmp, 0, array(xPDO::OPT_CACHE_KEY => 'modxtalks/users'))) {
             return false;
         }
     }
     return true;
 }
Example #24
0
/**
 * Disable/Reenable features modules.
 * We must do this when internal menu of module or permissions has changed
 * or when triggers have moved.
 *
 * @param	DoliDB		$db				Database handler
 * @param	Translate	$langs			Object langs
 * @param	Conf		$conf			Object conf
 * @param	array		$listofmodule	List of modules
 * @return	void
 */
function migrate_reload_modules($db, $langs, $conf, $listofmodule = array())
{
    dolibarr_install_syslog("upgrade2::migrate_reload_modules");
    // Module to reload if no info is provided
    if (count($listofmodule) == 0) {
        $listofmodule = array('MAIN_MODULE_AGENDA', 'MAIN_MODULE_SOCIETE', 'MAIN_MODULE_PRODUIT', 'MAIN_MODULE_SERVICE', 'MAIN_MODULE_COMMANDE', 'MAIN_MODULE_FACTURE', 'MAIN_MODULE_FOURNISSEUR', 'MAIN_MODULE_USER', 'MAIN_MODULE_DEPLACEMENT', 'MAIN_MODULE_DON', 'MAIN_MODULE_ECM', 'MAIN_MODULE_PAYBOX', 'MAIN_MODULE_OPENSURVEY');
    }
    foreach ($listofmodule as $moduletoreload) {
        if (empty($moduletoreload) || empty($conf->global->{$moduletoreload})) {
            continue;
        }
        if ($moduletoreload == 'MAIN_MODULE_AGENDA') {
            dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate module Agenda");
            $res = @(include_once DOL_DOCUMENT_ROOT . '/core/modules/modAgenda.class.php');
            if ($res) {
                $mod = new modAgenda($db);
                $mod->remove('noboxes');
                $mod->init('newboxdefonly');
            }
        }
        if ($moduletoreload == 'MAIN_MODULE_BARCODE') {
            dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate module Barcode");
            $res = @(include_once DOL_DOCUMENT_ROOT . '/core/modules/modBarcode.class.php');
            if ($res) {
                $mod = new modBarcode($db);
                $mod->remove('noboxes');
                $mod->init('newboxdefonly');
            }
        }
        if ($moduletoreload == 'MAIN_MODULE_CRON') {
            dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate module Cron");
            $res = @(include_once DOL_DOCUMENT_ROOT . '/core/modules/modCron.class.php');
            if ($res) {
                $mod = new modCron($db);
                $mod->remove('noboxes');
                $mod->init('newboxdefonly');
            }
        }
        if ($moduletoreload == 'MAIN_MODULE_SOCIETE') {
            dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate module Societe");
            $res = @(include_once DOL_DOCUMENT_ROOT . '/core/modules/modSociete.class.php');
            if ($res) {
                $mod = new modSociete($db);
                $mod->remove('noboxes');
                $mod->init('newboxdefonly');
            }
        }
        if ($moduletoreload == 'MAIN_MODULE_PRODUIT') {
            dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate module Produit");
            $res = @(include_once DOL_DOCUMENT_ROOT . '/core/modules/modProduct.class.php');
            if ($res) {
                $mod = new modProduct($db);
                //$mod->remove('noboxes');
                $mod->init('newboxdefonly');
            }
        }
        if ($moduletoreload == 'MAIN_MODULE_SERVICE') {
            dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate module Service");
            if ($res) {
                $res = @(include_once DOL_DOCUMENT_ROOT . '/core/modules/modService.class.php');
                $mod = new modService($db);
                //$mod->remove('noboxes');
                $mod->init('newboxdefonly');
            }
        }
        if ($moduletoreload == 'MAIN_MODULE_COMMANDE') {
            dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate module Commande");
            if ($res) {
                $res = @(include_once DOL_DOCUMENT_ROOT . '/core/modules/modCommande.class.php');
                $mod = new modCommande($db);
                //$mod->remove('noboxes');
                $mod->init('newboxdefonly');
            }
        }
        if ($moduletoreload == 'MAIN_MODULE_FACTURE') {
            dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate module Facture");
            if ($res) {
                $res = @(include_once DOL_DOCUMENT_ROOT . '/core/modules/modFacture.class.php');
                $mod = new modFacture($db);
                //$mod->remove('noboxes');
                $mod->init('newboxdefonly');
            }
        }
        if ($moduletoreload == 'MAIN_MODULE_FOURNISSEUR') {
            dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate module Fournisseur");
            $res = @(include_once DOL_DOCUMENT_ROOT . '/core/modules/modFournisseur.class.php');
            if ($res) {
                $mod = new modFournisseur($db);
                //$mod->remove('noboxes');
                $mod->init('newboxdefonly');
            }
        }
        if ($moduletoreload == 'MAIN_MODULE_DEPLACEMENT') {
            dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate module Deplacement");
            $res = @(include_once DOL_DOCUMENT_ROOT . '/core/modules/modDeplacement.class.php');
            if ($res) {
                $mod = new modDeplacement($db);
                //$mod->remove('noboxes');	// We need to remove because a permission id has been removed
                $mod->init('newboxdefonly');
            }
        }
        if ($moduletoreload == 'MAIN_MODULE_DON') {
            dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate module Don");
            $res = @(include_once DOL_DOCUMENT_ROOT . '/core/modules/modDon.class.php');
            if ($res) {
                $mod = new modDon($db);
                //$mod->remove('noboxes');	// We need to remove because a permission id has been removed
                $mod->init('newboxdefonly');
            }
        }
        if ($moduletoreload == 'MAIN_MODULE_ECM') {
            dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate module ECM");
            if ($res) {
                $res = @(include_once DOL_DOCUMENT_ROOT . '/core/modules/modECM.class.php');
                $mod = new modECM($db);
                $mod->remove('noboxes');
                // We need to remove because a permission id has been removed
                $mod->init('newboxdefonly');
            }
        }
        if ($moduletoreload == 'MAIN_MODULE_PAYBOX') {
            dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate module Paybox");
            $res = @(include_once DOL_DOCUMENT_ROOT . '/core/modules/modPaybox.class.php');
            if ($res) {
                $mod = new modPaybox($db);
                $mod->remove('noboxes');
                // We need to remove because id of module has changed
                $mod->init('newboxdefonly');
            }
        }
        if ($moduletoreload == 'MAIN_MODULE_OPENSURVEY') {
            dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate module Opensurvey");
            $res = @(include_once DOL_DOCUMENT_ROOT . '/core/modules/modOpenSurvey.class.php');
            if ($res) {
                $mod = new modOpenSurvey($db);
                $mod->remove('noboxes');
                // We need to remove because menu entries has changed
                $mod->init('newboxdefonly');
            }
        }
        if ($moduletoreload == 'MAIN_MODULE_USER') {
            dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate module User");
            $res = @(include_once DOL_DOCUMENT_ROOT . '/core/modules/modUser.class.php');
            if ($res) {
                $mod = new modUser($db);
                //$mod->remove('noboxes');  // We need to remove because id of module has changed
                $mod->init('newboxdefonly');
            }
        }
    }
}
Example #25
0
 /**
  * Called from modx plugin onlogin
  * @global modx $modx
  * @param modUser $oUser
  */
 public function onLoggedIn($oUser)
 {
     global $modx;
     FlexiLogger::info(__METHOD__, "user: "******"id")));
     $aGroupModel = $oUser->getMany("UserGroupMembers");
     $aGroup = array();
     FlexiLogger::info(__METHOD__, "Group cnt: " . count($aGroupModel));
     foreach ($aGroupModel as $oGroup) {
         $aDocGroup = $modx->getCollection("modAccessResourceGroup", array('principal_class' => 'modUserGroup', 'principal' => $oGroup->get("user_group")));
         //FlexiLogger::info(__METHOD__, "group id: " . $oGroup->get("user_group") . ", doc cnt: " . count($aDocGroup));
         foreach ($aDocGroup as $oDocGroup) {
             FlexiLogger::info(__METHOD__, "group id: " . $oDocGroup->get("target"));
             $aGroup[] = $docgroupid = $oDocGroup->get("target");
         }
     }
     $_SESSION['webDocgroups'] = $aGroup;
 }
 public function __construct(xPDO &$xpdo)
 {
     parent::__construct($xpdo);
     $this->set('class_key', 'vnewsUsers');
 }
Example #27
0
							}

							$couchdb->storeDoc($obj);

							fclose($fp);
						}	
					}
				}
				closedir($handle);
			}
			
			// Enable module User
			
			include_once($dolibarr_main_document_root . "/core/modules/modUser.class.php");
			
			$module = new modUser($couchdb);
			
			$module->values->_id = "module:".$module->values->name;
			$module->values->enabled = true;
			$module->values->class = "DolibarrModules";
			
			
			// Test if modUser exist in database
			try{
				$result = $couchdb->getDoc($module->values->_id);
				$module->values->_rev = $result->_rev;
			}catch(Exception $e){
				
			}
			
			$couchdb->storeDoc($module->values);
Example #28
0
 public function getPageTitle()
 {
     return $this->modx->lexicon('discuss.user') . ': ' . $this->user->get('username');
 }
Example #29
0
 /**
  * Used to send a notification email to a user for IPN notification.
  *
  * @param string $type Type of notification email to send.
  * @param \smSubscription $subscription The relevant Subscription object
  * @param \modUser $user The relevant User object.
  * @param \smProduct $product The relevant Product object
  * @param string|\smTransaction $transaction If a transaction is involved, the transaction object.
  * @return bool|string True if successful, an error message if not.
  */
 public function sendNotificationEmail($type = '', smSubscription $subscription, modUser $user, smProduct $product, $transaction = '')
 {
     $chunk = '';
     $subject = '';
     $phs = array();
     if (!$user instanceof modUser || !$subscription instanceof smSubscription || !$product instanceof smProduct) {
         $this->modx->log(MODX_LEVEL_ERROR, 'Error: invalid parameter(s) in SubscribeMe::sendNotificationEmail');
         return 'Invalid parameter(s) in SubscribeMe::sendNotificationEmail';
     }
     $up = $user->getOne('Profile');
     $userarray = $user->toArray();
     if ($up instanceof modUserProfile) {
         $userarray = array_merge($userarray, $up->toArray());
     }
     $phs = array('user' => $userarray, 'subscription' => $subscription->toArray(), 'product' => $product->toArray(), 'settings' => $this->modx->config);
     if ($transaction instanceof smTransaction) {
         $phs['transaction'] = $transaction->toArray();
     }
     switch ($type) {
         case 'recurring_payment_profile_cancel':
             $chunk = $this->modx->getOption('subscribeme.email.confirmcancel', null, 'smConfirmCancelEmail');
             $subject = $this->modx->getOption('subscribeme.email.confirmcancel.subject', null, 'Your recurring payments profile for [[+product]] has been canceled.');
             break;
         case 'recurring_payment_skipped':
             $chunk = $this->modx->getOption('subscribeme.email.notifyskippedpayment', null, 'smNotifySkippedPaymentEmail');
             $subject = $this->modx->getOption('subscribeme.email.notifyskippedpayment.subject', null, 'A payment for your [[+product]] subscription has been skipped.');
             break;
         case 'recurring_payment_expired':
             $chunk = $this->modx->getOption('subscribeme.email.paymentexpired', null, 'smPaymentExpiredEmail');
             $subject = $this->modx->getOption('subscribeme.email.paymentexpired.subject', null, 'Your Recurring Payment for [[+product]] has expired.');
             break;
         case 'recurring_payment_cancelledbyadmin':
             $chunk = $this->modx->getOption('subscribeme.email.confirmcancel.admin', null, 'smConfirmCancelAdminEmail');
             $subject = $this->modx->getOption('subscribeme.email.confirmcancel.admin.subject', null, 'An administrator has cancelled your [[+product]] subscription.');
             break;
         case 'subscription_expired':
             $chunk = $this->modx->getOption('subscribeme.email.subscriptionexpired', null, 'smSubscriptionExpiredEmail');
             $subject = $this->modx->getOption('subscribeme.email.subscriptionexpired.subject', null, 'Your [[+product]] Subscription Expired.');
             break;
     }
     $msg = $this->getChunk($chunk, $phs);
     $subject = str_replace(array('[[+product]]'), array($product->get('name')), $subject);
     if ($transaction instanceof smTransaction) {
         $subject = str_replace(array('[[+transid]]', '[[+transaction.method]]'), array($transaction->get('id'), $transaction->get('method')), $subject);
     }
     if ($user->sendEmail($msg, array('subject' => $subject)) !== true) {
         return 'Error sending email to user.';
     }
     return true;
 }
Example #30
0
 /**
  * Ensure passwordMatches works
  * @return void
  */
 public function testPasswordMatches()
 {
     $this->assertTrue($this->user->passwordMatches('boogles'));
     $this->assertFalse($this->user->passwordMatches('bugles'));
 }