Esempio n. 1
0
 /**
  * static public function for load user from login e password
  * @param string $login login of the user
  * @param string $password password of the user in clear text
  * @param string $prefix optional prefix for session publiciables
  * @return mixed DoceboUser instance of logged in user if success in login
  *				 FALSE otherwise
  **/
 public static function &createDoceboUserFromLogin($login, $password, $prefix = 'base', $new_lang = false)
 {
     if ($login == '') {
         $false_public = FALSE;
         return $false_public;
     }
     $user_manager = new DoceboACLManager();
     $user_info = $user_manager->getUser(false, $login);
     // first login
     $ret_value = false;
     if ($user_info === false) {
         return $ret_value;
     }
     if ($user_info[ACL_INFO_VALID] != '1') {
         return $ret_value;
     }
     if (Get::sett('ldap_used') == 'on') {
         if ($password == '') {
             $false_public = FALSE;
             return $false_public;
         }
         //connect to ldap server
         if (!($ldap_conn = @ldap_connect(Get::sett('ldap_server'), Get::sett('ldap_port', '389')))) {
             die("Could not connect to ldap server");
         }
         //bind on server
         $ldap_user = ereg_replace('\\$user', $login, Get::sett('ldap_user_string'));
         if (!@ldap_bind($ldap_conn, $ldap_user, $password)) {
             ldap_close($ldap_conn);
             // Edited by Claudio Redaelli
             if (Get::sett('ldap_alternate_check') == 'on') {
                 if ($user_info[ACL_INFO_PASS] != $user_manager->encrypt($password)) {
                     return $ret_value;
                 }
             } else {
                 $false_public = FALSE;
                 return $false_public;
             }
             // End edit
         }
         ldap_close($ldap_conn);
     } elseif ($user_info[ACL_INFO_PASS] != $user_manager->encrypt($password)) {
         return $ret_value;
     }
     unset($_SESSION[$prefix . "_idst"]);
     $du = new DoceboUser($login, $prefix);
     $_SESSION['last_enter'] = $user_info[ACL_INFO_LASTENTER];
     $du->setLastEnter(date("Y-m-d H:i:s"));
     $_SESSION['user_enter_mark'] = time();
     // language policy
     if (!$new_lang && isset($_SESSION['forced_lang'])) {
         $new_lang = Lang::get();
     }
     if ($new_lang != false) {
         $du->preference->setLanguage($new_lang);
     } else {
         if (!Get::cfg('demo_mode', false)) {
             Lang::set($du->preference->getLanguage());
         }
     }
     if (function_exists('session_regenerate_id')) {
         session_regenerate_id();
     }
     return $du;
 }
Esempio n. 2
0
function adminManager_assign_tree($adminidst)
{
    checkPerm('view');
    if ($adminidst == 0) {
        return;
    }
    require_once _base_ . '/lib/lib.form.php';
    require_once _base_ . '/lib/lib.userselector.php';
    require_once $GLOBALS['where_framework'] . '/lib/lib.adminmanager.php';
    $directory = new UserSelector();
    $lang =& DoceboLanguage::createInstance('adminrules', 'framework');
    $aclManager = new DoceboACLManager();
    $adminManager = new AdminManager();
    if (isset($_POST['okselector'])) {
        $arr_selected = $directory->getSelection($_POST);
        $arr_unselected = $directory->getUnselected();
        foreach ($arr_unselected as $idstTree) {
            $adminManager->removeAdminTree($idstTree, $adminidst);
        }
        foreach ($arr_selected as $idstTree) {
            $adminManager->addAdminTree($idstTree, $adminidst);
        }
        Util::jump_to('index.php?modname=admin_manager&op=view');
    } elseif (isset($_POST['cancelselector'])) {
        Util::jump_to('index.php?modname=admin_manager&op=view');
    } else {
        if (!isset($_GET['stayon'])) {
            $directory->resetSelection($adminManager->getAdminTree($adminidst));
        }
        $admin_info = $aclManager->getUser($adminidst, false);
        $directory->show_user_selector = FALSE;
        $directory->show_group_selector = TRUE;
        $directory->show_orgchart_selector = TRUE;
        $directory->show_orgchart_simple_selector = TRUE;
        $directory->multi_choice = TRUE;
        $directory->loadSelector('index.php?modname=admin_manager&amp;op=assign_tree&amp;adminidst=' . $adminidst . '&amp;stayon=1', $lang->def('_ASSIGN_USERS'), '<span class="text_bold">' . substr($admin_info[ACL_INFO_USERID], 1) . '</span>', TRUE);
    }
}
Esempio n. 3
0
 function show_report_LO($report_data = NULL, $other = '')
 {
     $jump_url = '';
     //show_report
     checkPerm('view');
     $lang =& DoceboLanguage::createInstance('report', 'framework');
     if (isset($_POST['send_mail_confirm'])) {
         $op = 'send_mail_confirm';
     } elseif (isset($_POST['send_mail'])) {
         $op = 'send_mail';
     } else {
         $op = 'show_result';
     }
     switch ($op) {
         case 'send_mail_confirm':
             $subject = importVar('mail_object', false, '[' . $lang->def('_SUBJECT') . ']');
             //'[No subject]');
             $body = importVar('mail_body', false, '');
             $acl_man = new DoceboACLManager();
             $user_info = $acl_man->getUser(getLogUserId(), false);
             if ($user_info) {
                 $sender = $user_info[ACL_INFO_EMAIL];
             }
             $mail_recipients = unserialize(urldecode(Get::req('mail_recipients', DOTY_STRING, '')));
             // prepare intestation for email
             $from = "From: " . $sender . $GLOBALS['mail_br'];
             $header = "MIME-Version: 1.0" . $GLOBALS['mail_br'] . "Content-type: text/html; charset=" . getUnicode() . $GLOBALS['mail_br'];
             $header .= "Return-Path: " . Get::sett('sender_event') . $GLOBALS['mail_br'];
             $header .= "Reply-To: " . Get::sett('sender_event') . $GLOBALS['mail_br'];
             $header .= "X-Sender: " . Get::sett('sender_event') . $GLOBALS['mail_br'];
             $header .= "X-Mailer: PHP/" . phpversion() . $GLOBALS['mail_br'];
             // send mail
             $arr_recipients = array();
             foreach ($mail_recipients as $recipient) {
                 $rec_data = $acl_man->getUser($recipient, false);
                 //mail($rec_data[ACL_INFO_EMAIL] , stripslashes($subject), stripslashes(nl2br($body)), $from.$header."\r\n");
                 $arr_recipients[] = $rec_data[ACL_INFO_EMAIL];
             }
             $mailer = DoceboMailer::getInstance();
             $mailer->SendMail($sender, $arr_recipients, stripslashes($subject), stripslashes(nl2br($body)));
             $result = getResultUi($lang->def('_OPERATION_SUCCESSFUL'));
             cout($this->_get_LO_query('html', NULL, $result));
             break;
         case 'send_mail':
             require_once _base_ . '/lib/lib.form.php';
             $mail_recipients = Get::req('mail_recipients', DOTY_MIXED, array());
             cout('' . Form::openElementSpace() . Form::getTextfield($lang->def('_SUBJECT'), 'mail_object', 'mail_object', 255) . Form::getTextarea($lang->def('_MAIL_BODY'), 'mail_body', 'mail_body') . Form::getHidden('mail_recipients', 'mail_recipients', urlencode(serialize($mail_recipients))) . Form::closeElementSpace() . Form::openButtonSpace() . Form::getButton('send_mail_confirm', 'send_mail_confirm', $lang->def('_SEND_MAIL')) . Form::getButton('undo_mail', 'undo_mail', $lang->def('_UNDO')) . Form::closeButtonSpace() . '</div>', 'content');
             break;
         default:
             cout($this->_get_LO_query('html', $report_data, $other));
     }
 }