Exemple #1
0
 /**
  * @param $ledgerTrans Ledger
  */
 private static function recordTransaction($ledgerTrans)
 {
     include_once $_SERVER['DOCUMENT_ROOT'] . "/bossflex/DB/Models/ClientAccount.php";
     $account = ClientAccount::getAccount($ledgerTrans->getAccountNum());
     $balance = $account->getBalance() + $ledgerTrans->getAmount();
     $account->setBalance($balance);
     ClientAccount::updateAccount($account);
 }
 /**
  * @param $AccountNum
  * @return ClientAccount
  */
 public static function getAccount($AccountNum)
 {
     include_once $_SERVER['DOCUMENT_ROOT'] . "/bossflex/DB/Conn.php";
     $sql = "SELECT *\n                FROM ClientAccount\n                WHERE AccountNum = :AccountNum";
     $stmt = Conn::get()->prepare($sql);
     $stmt->bindParam(":AccountNum", $AccountNum, PDO::PARAM_INT);
     $stmt->execute();
     $account = $stmt->fetchObject(__CLASS__);
     return $account ? $account : ClientAccount::openAccount($AccountNum);
 }
Exemple #3
0
 function getAccount()
 {
     if ($this->_account === false) {
         $this->_account = ClientAccount::lookup(array('user_id' => $this->getId()));
     }
     return $this->_account;
 }
Exemple #4
0
     $errors['err'] = __('Incomplete client information');
 } elseif (!$_POST['backend'] && !$_POST['passwd1']) {
     $errors['passwd1'] = __('New password is required');
 } elseif (!$_POST['backend'] && $_POST['passwd2'] != $_POST['passwd1']) {
     $errors['passwd1'] = __('Passwords do not match');
 } elseif (($addr = $user_form->getField('email')->getClean()) && ClientAccount::lookupByUsername($addr)) {
     $user_form->getField('email')->addError(sprintf(__('Email already registered. Would you like to %1$s sign in %2$s?'), '<a href="login.php?e=' . urlencode($addr) . '" style="color:inherit"><strong>', '</strong></a>'));
     $errors['err'] = __('Unable to register account. See messages below');
 } elseif (isset($_POST['backend']) && !($user = User::fromVars($user_form->getClean()))) {
     $errors['err'] = __('Unable to create local account. See messages below');
 } elseif (!$user && !$thisclient && !($user = User::fromVars($user_form->getClean()))) {
     $errors['err'] = __('Unable to register account. See messages below');
 } elseif (!$user && !($user = $thisclient ?: User::fromForm($user_form))) {
     $errors['err'] = __('Unable to register account. See messages below');
 } else {
     if (!($acct = ClientAccount::createForUser($user))) {
         $errors['err'] = __('Internal error. Unable to create new account');
     } elseif (!$acct->update($_POST, $errors)) {
         $errors['err'] = __('Errors configuring your profile. See messages below');
     }
 }
 if (!$errors) {
     switch ($_POST['do']) {
         case 'create':
             $content = Page::lookup(Page::getIdByType('registration-confirm'));
             $inc = 'register.confirm.inc.php';
             $acct->sendConfirmEmail();
             break;
         case 'import':
             if ($bk = UserAuthenticationBackend::getBackend($_POST['backend'])) {
                 $cl = new ClientSession(new EndUser($user));
Exemple #5
0
            break;
        case 'reset':
            $inc = 'pwreset.login.php';
            $errors = array();
            if ($client = UserAuthenticationBackend::processSignOn($errors)) {
                Http::redirect('index.php');
            } elseif (isset($errors['msg'])) {
                $banner = $errors['msg'];
            }
            break;
    }
} elseif ($_GET['token']) {
    $banner = __('Re-enter your username or email');
    $inc = 'pwreset.login.php';
    $_config = new Config('pwreset');
    if (($id = $_config->get($_GET['token'])) && ($acct = ClientAccount::lookup(array('user_id' => $id)))) {
        if (!$acct->isConfirmed()) {
            $inc = 'register.confirmed.inc.php';
            $acct->confirm();
            // TODO: Log the user in
            if ($client = UserAuthenticationBackend::processSignOn($errors)) {
                if ($acct->hasPassword() && !$acct->get('backend')) {
                    $acct->cancelResetTokens();
                } else {
                    $_SESSION['_client']['reset-token'] = $_GET['token'];
                    $acct->forcePasswdReset();
                }
                Http::redirect('account.php?confirmed');
            }
        }
    } elseif ($id && ($user = User::lookup($id))) {
Exemple #6
0
 function insertIntoEntityTable($table_name, $module, $fileid = '')
 {
     global $log;
     global $current_user, $app_strings;
     global $adb;
     $log->debug("Entering PaymentManagement::insertIntoEntityTable(" . $table_name . ", " . $module . ", " . $fileid . ") method ...");
     $value_table = array();
     $insertion_mode = $this->mode;
     //Checkin whether an entry is already is present in the vtiger_table to update
     if ($insertion_mode == 'edit') {
         $tablekey = $this->tab_name_index[$table_name];
         // Make selection on the primary key of the module table to check.
         $check_query = "select {$tablekey} from {$table_name} where {$tablekey}=?";
         $check_result = $adb->pquery($check_query, array($this->id));
         $num_rows = $adb->num_rows($check_result);
         if ($num_rows <= 0) {
             $insertion_mode = '';
         }
     }
     $tabid = getTabid($module);
     if ($insertion_mode == 'edit') {
         $update = array();
         $update_params = array();
         checkFileAccessForInclusion('user_privileges/user_privileges_' . $current_user->id . '.php');
         require 'user_privileges/user_privileges_' . $current_user->id . '.php';
         if ($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0) {
             $sql = "select * from vtiger_field where tabid in (" . generateQuestionMarks($tabid) . ") and tablename=? and displaytype in (1,3) and presence in (0,2) group by columnname";
             $params = array($tabid, $table_name);
         } else {
             $profileList = getCurrentUserProfileList();
             if (count($profileList) > 0) {
                 $sql = "SELECT *\n\t\t\t  \t\t\tFROM vtiger_field\n\t\t\t  \t\t\tINNER JOIN vtiger_profile2field\n\t\t\t  \t\t\tON vtiger_profile2field.fieldid = vtiger_field.fieldid\n\t\t\t  \t\t\tINNER JOIN vtiger_def_org_field\n\t\t\t  \t\t\tON vtiger_def_org_field.fieldid = vtiger_field.fieldid\n\t\t\t  \t\t\tWHERE vtiger_field.tabid = ?\n\t\t\t  \t\t\tAND vtiger_profile2field.visible = 0 AND vtiger_profile2field.readonly = 0\n\t\t\t  \t\t\tAND vtiger_profile2field.profileid IN (" . generateQuestionMarks($profileList) . ")\n\t\t\t  \t\t\tAND vtiger_def_org_field.visible = 0 and vtiger_field.tablename=? and vtiger_field.displaytype in (1,3) and vtiger_field.presence in (0,2) group by columnname";
                 $params = array($tabid, $profileList, $table_name);
             } else {
                 $sql = "SELECT *\n\t\t\t  \t\t\tFROM vtiger_field\n\t\t\t  \t\t\tINNER JOIN vtiger_profile2field\n\t\t\t  \t\t\tON vtiger_profile2field.fieldid = vtiger_field.fieldid\n\t\t\t  \t\t\tINNER JOIN vtiger_def_org_field\n\t\t\t  \t\t\tON vtiger_def_org_field.fieldid = vtiger_field.fieldid\n\t\t\t  \t\t\tWHERE vtiger_field.tabid = ?\n\t\t\t  \t\t\tAND vtiger_profile2field.visible = 0 AND vtiger_profile2field.readonly = 0\n\t\t\t  \t\t\tAND vtiger_def_org_field.visible = 0 and vtiger_field.tablename=? and vtiger_field.displaytype in (1,3) and vtiger_field.presence in (0,2) group by columnname";
                 $params = array($tabid, $table_name);
             }
         }
     } else {
         $table_index_column = $this->tab_name_index[$table_name];
         if ($table_index_column == 'id' && $table_name == 'vtiger_users') {
             $currentuser_id = $adb->getUniqueID("vtiger_users");
             $this->id = $currentuser_id;
         }
         $columname = $table_index_column;
         $fldvalue = $this->id;
         $column = array($table_index_column);
         $value = array($this->id);
         // vtiger_payment_management のインデックスを登録 (2015/11/26)
         $columname = $table_index_column;
         // tao
         $fldvalue = $this->id;
         // tao
         $value_table[$columname] = $fldvalue;
         // tao
         $sql = "select * from vtiger_field where tabid=? and tablename=? and displaytype in (1,3,4) and vtiger_field.presence in (0,2)";
         $params = array($tabid, $table_name);
     }
     // Attempt to re-use the quer-result to avoid reading for every save operation
     // TODO Need careful analysis on impact ... MEMORY requirement might be more
     static $_privatecache = array();
     $cachekey = "{$insertion_mode}-" . implode(',', $params);
     if (!isset($_privatecache[$cachekey])) {
         $result = $adb->pquery($sql, $params);
         $noofrows = $adb->num_rows($result);
         if (CRMEntity::isBulkSaveMode()) {
             $cacheresult = array();
             for ($i = 0; $i < $noofrows; ++$i) {
                 $cacheresult[] = $adb->fetch_array($result);
             }
             $_privatecache[$cachekey] = $cacheresult;
         }
     } else {
         // Useful when doing bulk save
         $result = $_privatecache[$cachekey];
         $noofrows = count($result);
     }
     for ($i = 0; $i < $noofrows; $i++) {
         $fieldname = $this->resolve_query_result_value($result, $i, "fieldname");
         $columname = $this->resolve_query_result_value($result, $i, "columnname");
         $uitype = $this->resolve_query_result_value($result, $i, "uitype");
         $generatedtype = $this->resolve_query_result_value($result, $i, "generatedtype");
         $typeofdata = $this->resolve_query_result_value($result, $i, "typeofdata");
         $typeofdata_array = explode("~", $typeofdata);
         $datatype = $typeofdata_array[0];
         $ajaxSave = false;
         // uitype == 2
         if ($_REQUEST['file'] == 'DetailViewAjax' && $_REQUEST['ajxaction'] == 'DETAILVIEW' && isset($_REQUEST["fldName"]) && $_REQUEST["fldName"] != $fieldname || $_REQUEST['action'] == 'MassEditSave' && !isset($_REQUEST[$fieldname . "_mass_edit_check"])) {
             $ajaxSave = true;
         }
         if ($uitype == 4 && $insertion_mode != 'edit') {
             $fldvalue = '';
             // Bulk Save Mode: Avoid generation of module sequence number, take care later.
             if (!CRMEntity::isBulkSaveMode()) {
                 $fldvalue = $this->setModuleSeqNumber("increment", $module);
             }
             $this->column_fields[$fieldname] = $fldvalue;
         }
         if (isset($this->column_fields[$fieldname])) {
             if ($uitype == 56) {
                 if ($this->column_fields[$fieldname] == 'on' || $this->column_fields[$fieldname] == 1) {
                     $fldvalue = '1';
                 } else {
                     $fldvalue = '0';
                 }
             } elseif ($uitype == 15 || $uitype == 16) {
                 if ($this->column_fields[$fieldname] == $app_strings['LBL_NOT_ACCESSIBLE']) {
                     //If the value in the request is Not Accessible for a picklist,
                     //the existing value will be replaced instead of Not Accessible value.
                     $sql = "select {$columname} from  {$table_name} where " . $this->tab_name_index[$table_name] . "=?";
                     $res = $adb->pquery($sql, array($this->id));
                     $pick_val = $adb->query_result($res, 0, $columname);
                     $fldvalue = $pick_val;
                 } else {
                     $fldvalue = $this->column_fields[$fieldname];
                 }
             } elseif ($uitype == 33) {
                 if (is_array($this->column_fields[$fieldname])) {
                     $field_list = implode(' |##| ', $this->column_fields[$fieldname]);
                 } else {
                     $field_list = $this->column_fields[$fieldname];
                 }
                 $fldvalue = $field_list;
             } elseif ($uitype == 5 || $uitype == 6 || $uitype == 23) {
                 //Added to avoid function call getDBInsertDateValue in ajax save
                 if (isset($current_user->date_format) && !$ajaxSave) {
                     $fldvalue = getValidDBInsertDateValue($this->column_fields[$fieldname]);
                 } else {
                     $fldvalue = $this->column_fields[$fieldname];
                 }
             } elseif ($uitype == 7) {
                 //strip out the spaces and commas in numbers if given ie., in amounts there may be ,
                 $fldvalue = str_replace(",", "", $this->column_fields[$fieldname]);
                 //trim($this->column_fields[$fieldname],",");
             } elseif ($uitype == 26) {
                 if (empty($this->column_fields[$fieldname])) {
                     $fldvalue = 1;
                     //the documents will stored in default folder
                 } else {
                     $fldvalue = $this->column_fields[$fieldname];
                 }
             } elseif ($uitype == 28) {
                 if ($this->column_fields[$fieldname] == null) {
                     $fileQuery = $adb->pquery("SELECT filename from vtiger_notes WHERE notesid = ?", array($this->id));
                     $fldvalue = null;
                     if (isset($fileQuery)) {
                         $rowCount = $adb->num_rows($fileQuery);
                         if ($rowCount > 0) {
                             $fldvalue = decode_html($adb->query_result($fileQuery, 0, 'filename'));
                         }
                     }
                 } else {
                     $fldvalue = decode_html($this->column_fields[$fieldname]);
                 }
             } elseif ($uitype == 8) {
                 $this->column_fields[$fieldname] = rtrim($this->column_fields[$fieldname], ',');
                 $ids = explode(',', $this->column_fields[$fieldname]);
                 $json = new Zend_Json();
                 $fldvalue = $json->encode($ids);
             } elseif ($uitype == 12) {
                 // Bulk Sae Mode: Consider the FROM email address as specified, if not lookup
                 $fldvalue = $this->column_fields[$fieldname];
                 if (empty($fldvalue)) {
                     $query = "SELECT email1 FROM vtiger_users WHERE id = ?";
                     $res = $adb->pquery($query, array($current_user->id));
                     $rows = $adb->num_rows($res);
                     if ($rows > 0) {
                         $fldvalue = $adb->query_result($res, 0, 'email1');
                     }
                 }
                 // END
             } elseif ($uitype == 72 && !$ajaxSave) {
                 // Some of the currency fields like Unit Price, Totoal , Sub-total - doesn't need currency conversion during save
                 $fldvalue = CurrencyField::convertToDBFormat($this->column_fields[$fieldname], null, true);
             } elseif ($uitype == 71 && !$ajaxSave) {
                 $fldvalue = CurrencyField::convertToDBFormat($this->column_fields[$fieldname]);
             } else {
                 $fldvalue = $this->column_fields[$fieldname];
             }
             if ($uitype != 33 && $uitype != 8) {
                 $fldvalue = from_html($fldvalue, $insertion_mode == 'edit' ? true : false);
             }
         } else {
             $fldvalue = '';
         }
         if ($fldvalue == '') {
             $fldvalue = $this->get_column_value($columname, $fldvalue, $fieldname, $uitype, $datatype);
         }
         // key-value 配列にキーと値の組を登録する
         $value_table[$columname] = $fldvalue;
         // tao
         if ($insertion_mode == 'edit') {
             if ($table_name != 'vtiger_ticketcomments' && $uitype != 4) {
                 array_push($update, $columname . "=?");
                 array_push($update_params, $fldvalue);
             }
         } else {
             array_push($column, $columname);
             array_push($value, $fldvalue);
         }
     }
     if ($insertion_mode == 'edit') {
         // ADDED by tao on 15/12/04 -- begin
         if ($table_name == 'vtiger_client_account') {
             $sql = 'update vtiger_crmentityrel set crmid=? where relcrmid=?';
             $param = array($value_table['accountid'], $this->id);
             $update_params = ClientAccount::generateValues($value_table);
             $adb->pquery($sql, $param);
         }
         // ADDED by tao on 15/12/04 -- end
         //Check done by Don. If update is empty the the query fails
         if (count($update) > 0) {
             $sql1 = "update {$table_name} set " . implode(",", $update) . " where " . $this->tab_name_index[$table_name] . "=?";
             array_push($update_params, $this->id);
             $adb->pquery($sql1, $update_params, true);
         }
     } else {
         // Added by 田尾 (tao) on 15/11/25 -- begin
         if ($table_name == 'vtiger_client_account') {
             $this->save_related_module('Account', $value_table['accountid'], 'ClientAccount', $value_table['client_account_id']);
         }
         $value = ClientAccount::generateValues($value_table);
         // Added by 田尾 (tao) on 15/11/25 -- end
         $sql1 = "insert into {$table_name}(" . implode(",", $column) . ") values(" . generateQuestionMarks($value) . ")";
         $adb->pquery($sql1, $value);
     }
     $log->debug("Exting PaymentManagement::insertIntoEntityTable(" . $table_name . ", " . $module . ", " . $fileid . ") method ...");
 }
Exemple #7
0
 function signOn($errors = array())
 {
     global $ost;
     if (!isset($_GET['token'])) {
         return false;
     } elseif (!($_config = new Config('pwreset'))) {
         return false;
     } elseif (!($id = $_config->get($_GET['token']))) {
         return false;
     } elseif (!($acct = ClientAccount::lookup(array('user_id' => $id))) || !$acct->getId() || $id != $acct->getUserId() || !($client = new ClientSession(new EndUser($acct->getUser())))) {
         return false;
     } else {
         return $client;
     }
 }
Exemple #8
0
            $errors = array();
            if ($client = UserAuthenticationBackend::processSignOn($errors)) {
                Http::redirect('index.php');
            }
            elseif (isset($errors['msg'])) {
                $banner = $errors['msg'];
            }
            break;
    }
}
elseif ($_GET['token']) {
    $banner = __('Re-enter your username or email');
    $inc = 'pwreset.login.php';
    $_config = new Config('pwreset');
    if (($id = $_config->get($_GET['token']))
            && ($acct = ClientAccount::lookup(array('user_id'=>$id)))) {
        if (!$acct->isConfirmed()) {
            $inc = 'register.confirmed.inc.php';
            $acct->confirm();
            // TODO: Log the user in
            if ($client = UserAuthenticationBackend::processSignOn($errors)) {
                if ($acct->hasPassword() && !$acct->get('backend')) {
                    $acct->cancelResetTokens();
                }
                // No password setup yet -- force one to be created
                else {
                    $_SESSION['_client']['reset-token'] = $_GET['token'];
                    $acct->forcePasswdReset();
                }
                Http::redirect('account.php?confirmed');
            }
Exemple #9
0
 function signOn()
 {
     global $cfg;
     if (isset($_SESSION[':cas'])) {
         $acct = ClientAccount::lookupByUsername($this->cas->getEmail());
         $client = null;
         if ($acct && $acct->getId()) {
             $client = new ClientSession(new EndUser($acct->getUser()));
         }
         if (!$client) {
             $client = new ClientCreateRequest($this, $this->cas->getEmail(), $this->cas->getProfile());
             if (!$cfg || !$cfg->isClientRegistrationEnabled() && self::$config->get('cas-force-register')) {
                 $client = $client->attemptAutoRegister();
             }
         }
         return $client;
     }
 }
Exemple #10
0
function createTicketByWebService($xml)
{
    global $logFilePath;
    try {
        if (!empty($xml)) {
            $nodes = $xml->xpath('/contacts/contact');
        } else {
            logErrors("The xml file can not be loaded ");
        }
        for ($i = 0; $i < count($nodes); $i++) {
            // echo json_encode($nodes[$i]);
            $data = array();
            // $data['recipients'] = array();
            $data['subject'] = removeLineBreaker($nodes[$i]->title);
            if (empty(removeLineBreaker($nodes[$i]->title))) {
                if (!empty(removeLineBreaker($nodes[$i]->crmsubject2_text))) {
                    $data['subject'] = removeLineBreaker($nodes[$i]->crmsubject2_text);
                } else {
                    $data['subject'] = "no title";
                }
            }
            $data['header'] = "";
            // $data['mid'] = 1;
            $data['source'] = "Web";
            $data['topicId'] = 2;
            $data['priorityId'] = 2;
            $data['crm_contact_id'] = $nodes[$i]->attributes()->id;
            // $data['flags'] = new ArrayObject();
            $data['email'] = trim(removeLineBreaker($nodes[$i]->email));
            if (empty($data['email'])) {
                $data['email'] = "*****@*****.**";
            }
            $data['phone'] = removeLineBreaker($nodes[$i]->phone);
            if (empty($data['phone'])) {
                $data['phone'] = "";
            }
            $data['name'] = trim(removeLineBreaker($nodes[$i]->name));
            if (empty($data['name'])) {
                $data['name'] = "Anonymous User";
            }
            $data['orderNumber'] = trim(removeLineBreaker($nodes[$i]->ordernumber));
            $data['ordernumber'] = trim(removeLineBreaker($nodes[$i]->ordernumber));
            $data['filenumber'] = trim(removeLineBreaker($nodes[$i]->filenumber));
            $data['cvr'] = trim(removeLineBreaker($nodes[$i]->cvr));
            $data['CVR'] = trim(removeLineBreaker($nodes[$i]->cvr));
            $data['message'] = removeLineBreaker($nodes[$i]->content);
            $data['companyName'] = removeLineBreaker($nodes[$i]->companyname);
            $data['company'] = removeLineBreaker($nodes[$i]->companyname);
            $data['business_form_id'] = removeLineBreaker($nodes[$i]->business_form_id);
            $data['activityCode'] = removeLineBreaker($nodes[$i]->activitycode);
            $data['activityDescription'] = removeLineBreaker($nodes[$i]->activitydescription);
            $data['useragent'] = removeLineBreaker($nodes[$i]->useragent);
            $crmsubject1_id = trim(removeLineBreaker($nodes[$i]->crmsubject_id));
            if (is_numeric($crmsubject1_id)) {
                $data['CRM_filter_subject1'] = removeLineBreaker($nodes[$i]->crmsubject_text);
                $data['crmsubject1_id'] = intval($crmsubject1_id);
                $data['crmsubject1_text'] = removeLineBreaker($nodes[$i]->crmsubject_text);
            } else {
                die("crmsubject1_id is not numeric");
            }
            $crmsubject2_id = trim(removeLineBreaker($nodes[$i]->crmsubject2_id));
            if (is_numeric($crmsubject2_id)) {
                $data['CRM_filter_subject2'] = removeLineBreaker($nodes[$i]->crmsubject2_text);
                $data['crmsubject2_id'] = intval($crmsubject2_id);
                $data['crmsubject2_text'] = removeLineBreaker($nodes[$i]->crmsubject2_text);
            } else {
                die("crmsubject2_id is not numeric");
            }
            // $data['flags']['bounce'] = true;
            $user = null;
            $acct = null;
            if (!$user && $data['email']) {
                $user = User::lookupByEmail($data['email']);
            }
            if (!$user) {
                $user_form = UserForm::getUserForm()->getForm($data);
                if (!($user = User::fromVars($user_form->getClean()))) {
                    echo 'Unable to register account.';
                }
                if (!($acct = ClientAccount::createForUser($user))) {
                    echo 'Internal error. Unable to create new account';
                }
            }
            $fileContent = $nodes[$i]->files->file;
            $data['fileContent'] = $fileContent;
            $tform = TicketForm::objects()->one()->getForm();
            $messageField = $tform->getField('message');
            $fileField = $messageField->getWidget()->getAttachments();
            for ($j = 0; $j < count($fileContent); $j++) {
                $fileId = $fileContent[$j]->attributes()->id;
                $file['name'] = $fileContent[$j]->name;
                $file['type'] = $fileContent[$j]->mime;
                $file['encoding'] = 'base64';
                // $file['cid'] = false;
                $url = "https://w2l.dk" . $fileContent[$j]->url;
                // logErrors("A test");
                // $url = $fileContent[$j]->url;
                // $file['data'] = base64_encode(file_get_contents($url));
                if ($file['data'] = getFileContentsSSL($url)) {
                    $timestamp = date("Y-m-d_H:i:s");
                    // if(!file_put_contents(CLIENTINC_DIR.'erstFile/'.$timestamp.$file['name'], $file['data']))
                    //     logErrors("not able to store the file");
                    try {
                        $storeCRMFile = "/var/www/html/erstFile/" . $timestamp . $file['name'];
                        echo $storeCRMFile;
                        file_put_contents("/var/www/html/erstFile/" . $timestamp . $file['name'], $file['data']);
                    } catch (Exception $e) {
                        logErrors('Caught exception: ', $e->getMessage(), "\n");
                    }
                } else {
                    logErrors("The file url is not valid");
                }
                // try {
                //     $file['id'] = $fileField->uploadAttachment($file);
                // }
                // catch (FileUploadError $ex) {
                //     $file['error'] = $file['name'] . ': ' . $ex->getMessage();
                //     echo $file['error'];
                // }
                $data['attachments'][] = $file;
                // echo $file['data'];
                // echo "<br/>";
            }
            // echo "22222";
            // echo json_encode($data);
            if (Ticket::lookupForContactId($data['crm_contact_id'])) {
                $api = new TicketApiController();
                $api->createTicket($data);
                echo "ticket has been generated successfully <br/>";
                if (DELETE_ERST_SERVICE_QUEUE) {
                    deleteContactsFromQueue($data['crm_contact_id']);
                } else {
                    logErrors("please go to include/ost-config to make the DELETE_ERST_SERVICE_QUEUE to true");
                }
            } else {
                logErrors("ticket with id " . $data['crm_contact_id'] . " has already exists");
            }
        }
    } catch (Exception $e) {
        echo 'Caught exception: ', $e->getMessage(), "\n";
    }
}
 function authOrCreate($username)
 {
     global $cfg;
     switch ($this->type) {
         case 'staff':
             if (($user = StaffSession::lookup($username)) && $user->getId()) {
                 if (!$user instanceof StaffSession) {
                     // osTicket <= v1.9.7 or so
                     $user = new StaffSession($user->getId());
                 }
                 return $user;
             } else {
                 $staff_groups = preg_split('/;|,/', $config->get('multiauth-staff-group'));
                 $chkgroup;
                 foreach ($staff_groups as $staff_group) {
                     if ($ldap->checkGroup($name, $staff_group)) {
                         $chkgroup = true;
                         break;
                     }
                 }
                 $config = $this->getConfig();
                 if ($config->get('multiauth-staff-register') && $chkgroup) {
                     if (!($info = $this->lookup($username, false))) {
                         return;
                     }
                     $errors = array();
                     $staff = array();
                     $staff['username'] = $info['username'];
                     $staff['firstname'] = $info['first'];
                     $staff['lastname'] = $info['last'];
                     $staff['email'] = $info['email'];
                     $staff['isadmin'] = 0;
                     $staff['isactive'] = 1;
                     $staff['group_id'] = 1;
                     $staff['dept_id'] = 1;
                     $staff['welcome_email'] = "on";
                     $staff['timezone_id'] = 8;
                     $staff['isvisible'] = 1;
                     Staff::create($staff, $errors);
                     if (($user = StaffSession::lookup($username)) && $user->getId()) {
                         if (!$user instanceof StaffSession) {
                             $user = new StaffSession($user->getId());
                         }
                         return $user;
                     }
                 }
             }
             break;
         case 'client':
             // Lookup all the information on the user. Try to get the email
             // addresss as well as the username when looking up the user
             // locally.
             if (!($info = $this->search($username)[0])) {
                 return;
             }
             $acct = ClientAccount::lookupByUsername($username);
             if ($acct && $acct->getId()) {
                 $client = new ClientSession(new EndUser($acct->getUser()));
             }
             if (!$client) {
                 $info['name'] = $info['first'] . " " . $info['last'];
                 $client = new ClientCreateRequest($this, $username, $info);
                 //if (!$cfg || !$cfg->isClientRegistrationEnabled() && self::$config->get('multiauth-force-register')) {
                 // return $client->attemptAutoRegister();
                 //}
             }
             return $client;
     }
     return null;
 }
Exemple #12
0
 /**
  * @return ClientAccount
  */
 public function getAccount()
 {
     include_once $_SERVER['DOCUMENT_ROOT'] . "/bossflex/DB/Models/ClientAccount.php";
     return ClientAccount::getAccount($this->AccountNum);
 }