public function put($uid)
 {
     $token = Input::get('token');
     $result = $this->contextIO->getConnectToken(null, $token);
     if (!$result) {
         return ['success' => 'false', 'error_message' => 'Failed to retrieve a connect token from context.io'];
     }
     $response = $result->getData();
     $responseJSON = json_encode($response);
     $response = json_decode($responseJSON);
     $data = $response->account;
     $serviceMap = ['imap.googlemail.com' => 'gmail', 'imap-mail.outlook.com:993' => 'outlook'];
     $desired_data = ['email_address' => $data->email_addresses[0], 'mailbox_id' => $data->id, 'service' => isset($serviceMap[$data->sources[0]->server]) ? $serviceMap[$data->sources[0]->server] : 'other'];
     $account = new Mailbox();
     $account->id = $uid;
     $account->mailbox_id = $desired_data['mailbox_id'];
     $account->email_address = $desired_data['email_address'];
     $account->service = $desired_data['service'];
     if (!$account->save()) {
         return ['success' => false, 'error_message' => 'Failed to save account details'];
     }
     // TODO: Start sync process
     // Queue Mailbox crawl
     try {
         Queue::push('ContextIOCrawlerController@dequeue', ['id' => $uid], 'contextio.sync.' . Config::get('queue.postfix'));
     } catch (Exception $e) {
         return ['success' => false, 'error_message' => $e->getMessage()];
     }
     return ['success' => true];
 }
示例#2
0
 public function actionTest()
 {
     $mailbox = new Mailbox('{imap.gmail.com:993/imap/ssl}INBOX', '*****@*****.**', '2uvsKCrDU7MkXQKPxkXs');
     // Read all messaged into an array:
     $mailsIds = $mailbox->searchMailbox('ALL');
     var_dump($mailbox);
 }
 public function actionInfo($id)
 {
     //		$cs =$this->module->getClientScript();
     //		$cs->registerScriptFile($this->module->getAssetsUrl().'/js/message.js');
     //		$js = '$(".mailbox-message-list").yiiMailboxMessage('.$this->module->getOptions().");";
     //		$cs->registerScript('mailbox-js',$js,CClientScript::POS_READY);
     $conv = Mailbox::conversation($id);
     $reply = new Message();
     $this->render('info', array('conv' => $conv, 'reply' => $reply));
 }
示例#4
0
function getSidebarMessages() {
    global $uid, $urlServer, $langFrom, $dateFormatLong, $langDropboxNoMessage, $langMailSubject, $langCourse;

    $message_content = '';

    $mbox = new Mailbox($uid, 0);
    $msgs = $mbox->getInboxMsgs('');

    $msgs = array_filter($msgs, function ($msg) { return !$msg->is_read; });
    if (!count($msgs)) {
        $message_content .= "<li class='list-item no-messages'>" .
                            "<span class='item-wholeline'>" .
                                $langDropboxNoMessage .
                            "</span>" .
                         "</li>";
    } else {
        foreach ($msgs as $message) {
            if ($message->course_id > 0) {
                $course_title = q(ellipsize(course_id_to_title($message->course_id), 30));
            } else {
                $course_title = '';
            }

            $message_date = claro_format_locale_date($dateFormatLong, $message->timestamp);
            $message_content .= "<li class='list-item'>
                            <span class='item-wholeline'>
                                <div class='text-title'>$langFrom: " .
                                    display_user($message->author_id, false, false) . "<br>
                                    $langMailSubject: <a href='{$urlServer}modules/dropbox/index.php?mid=$message->id'>" .
                                        q($message->subject) . "</a>
                                </div>";
                                    if ($course_title) {
                                       $message_content .= "<div class='text-grey'>$langCourse: $course_title</div>"; 
                                    }
                                $message_content .= "<div>$message_date</div>
                                </span>
                            </li>";
        }
    }
    return $message_content;
}
 function SendEmail()
 {
     if ($this->Account == null) {
         $this->Account = Mailbox::GetDefaultOutgoing();
     }
     if ($this->Account == null) {
         return null;
     }
     if ($this->Account->Type == "SMTP") {
         if ($this->Account->Framework == "PHP_MAILER") {
             return false;
         } else {
             $this->Result = $this->SEND_SMTP_ZEND();
         }
     } else {
         if ($this->Account->Type == "PHPMail") {
             $this->Result = $this->SEND_PHP_MAIL($this->Receiver);
         }
     }
 }
 function SendEmail($_fakeSender = "")
 {
     if ($this->Mailbox == null) {
         $this->Mailbox = Mailbox::GetDefaultOutgoing();
     }
     if ($this->Mailbox == null) {
         return null;
     }
     $this->FakeSender = $_fakeSender;
     if ($this->Mailbox->Type == "SMTP") {
         if ($this->Mailbox->Framework == "PHP_MAILER") {
             return false;
         } else {
             $this->Result = $this->SEND_SMTP_ZEND();
         }
     } else {
         if ($this->Mailbox->Type == "PHPMail") {
             $this->Result = $this->SEND_PHP_MAIL($this->Receiver);
         }
     }
 }
 public static function conversation($id, $order = 'DESC')
 {
     if (!is_int((int) $id)) {
         throw new Exception('Bad conversation Id');
     }
     $with = array('messages' => array('order' => 'created ' . $order));
     return Mailbox::model()->with($with)->findByPk($id);
 }
示例#8
0
 public function actionView()
 {
     $this->module->registerConfig($this->getAction()->getId());
     $cs =& $this->module->getClientScript();
     $cs->registerScriptFile($this->module->getAssetsUrl() . '/js/message.js');
     $js = '$(".mailbox-message-list").yiiMailboxMessage(' . $this->module->getOptions() . ");";
     $cs->registerScript('mailbox-js', $js, CClientScript::POS_READY);
     $conv = Mailbox::conversation($_GET['id']);
     $conv->markRead($this->module->getUserId());
     $reply = new Message();
     $this->render('message', array('conv' => $conv, 'reply' => $reply));
 }
示例#9
0
/**
 * Function lessonToolsMenu
 *
 * Creates a multi-dimensional array of the user's tools
 * in regard to the user's user level
 * (student | professor | platform administrator)
 *
 * @return array
 */
function lessonToolsMenu()
{
    global $uid, $is_editor, $is_course_admin;
    global $course_code, $langAdministrationTools, $langExternalLinks;
    global $modules, $admin_modules, $urlAppend;
    $sideMenuGroup = array();
    $sideMenuSubGroup = array();
    $sideMenuText = array();
    $sideMenuLink = array();
    $sideMenuImg = array();
    $sideMenuID = array();
    $arrMenuType = array();
    $arrMenuType['type'] = 'none';
    if ($is_editor) {
        $tools_sections = array(array('type' => 'Public', 'title' => $GLOBALS['langActiveTools'], 'iconext' => '_on.png', 'class' => 'active'), array('type' => 'PublicButHide', 'title' => $GLOBALS['langInactiveTools'], 'iconext' => '_off.png', 'class' => 'inactive'));
    } else {
        $tools_sections = array(array('type' => 'Public', 'title' => $GLOBALS['langCourseOptions'], 'iconext' => '_on.png', 'class' => 'active'));
    }
    foreach ($tools_sections as $section) {
        $result = getToolsArray($section['type']);
        $sideMenuSubGroup = array();
        $sideMenuText = array();
        $sideMenuLink = array();
        $sideMenuImg = array();
        $sideMenuID = array();
        $arrMenuType = array('type' => 'text', 'text' => $section['title'], 'class' => $section['class']);
        array_push($sideMenuSubGroup, $arrMenuType);
        foreach ($result as $toolsRow) {
            $mid = $toolsRow->module_id;
            if ($mid == MODULE_ID_DROPBOX) {
                require_once 'modules/dropbox/class.mailbox.php';
                $mbox = new Mailbox($uid, course_code_to_id($course_code));
                $new_msgs = $mbox->unreadMsgsNumber();
                if ($new_msgs != 0) {
                    array_push($sideMenuText, "<b>" . q($modules[$mid]['title']) . " (" . $new_msgs . ")</b>");
                } else {
                    array_push($sideMenuText, q($modules[$mid]['title']));
                }
            } else {
                array_push($sideMenuText, q($modules[$mid]['title']));
            }
            array_push($sideMenuLink, q($urlAppend . 'modules/' . $modules[$mid]['link'] . '/?course=' . $course_code));
            array_push($sideMenuImg, $modules[$mid]['image'] . $section['iconext']);
            array_push($sideMenuID, $mid);
        }
        array_push($sideMenuSubGroup, $sideMenuText);
        array_push($sideMenuSubGroup, $sideMenuLink);
        array_push($sideMenuSubGroup, $sideMenuImg);
        array_push($sideMenuSubGroup, $sideMenuID);
        array_push($sideMenuGroup, $sideMenuSubGroup);
    }
    $result2 = getExternalLinks();
    if ($result2) {
        // display external link (if any)
        $sideMenuSubGroup = array();
        $sideMenuText = array();
        $sideMenuLink = array();
        $sideMenuImg = array();
        $arrMenuType = array('type' => 'text', 'text' => $langExternalLinks, 'class' => 'external');
        array_push($sideMenuSubGroup, $arrMenuType);
        foreach ($result2 as $ex_link) {
            array_push($sideMenuText, q($ex_link->title));
            array_push($sideMenuLink, q($ex_link->url));
            array_push($sideMenuImg, "external_link" . $section['iconext']);
        }
        array_push($sideMenuSubGroup, $sideMenuText);
        array_push($sideMenuSubGroup, $sideMenuLink);
        array_push($sideMenuSubGroup, $sideMenuImg);
        array_push($sideMenuGroup, $sideMenuSubGroup);
    }
    if ($is_course_admin) {
        // display course admin tools
        $sideMenuSubGroup = array();
        $sideMenuText = array();
        $sideMenuLink = array();
        $sideMenuImg = array();
        $sideMenuID = array();
        $arrMenuType = array('type' => 'text', 'text' => $langAdministrationTools, 'class' => 'course_admin');
        array_push($sideMenuSubGroup, $arrMenuType);
        foreach ($admin_modules as $adm_mod) {
            array_push($sideMenuText, $adm_mod['title']);
            array_push($sideMenuLink, q($urlAppend . 'modules/' . $adm_mod['link'] . '/?course=' . $course_code));
            array_push($sideMenuImg, $adm_mod['image'] . $section['iconext']);
        }
        array_push($sideMenuSubGroup, $sideMenuText);
        array_push($sideMenuSubGroup, $sideMenuLink);
        array_push($sideMenuSubGroup, $sideMenuImg);
        array_push($sideMenuSubGroup, $sideMenuID);
        array_push($sideMenuGroup, $sideMenuSubGroup);
    }
    return $sideMenuGroup;
}
示例#10
0
     break;
 case validateRoute('GET', 'mailbox'):
     $mailbox = new Mailbox($db, $user);
     list($result, $totalCount) = $mailbox->query((int) $_GET["location"] ?: 0, (int) $_GET["limit"] ?: 10, (int) $_GET["index"] ?: 0);
     httpResponse($result, $totalCount);
     break;
 case validateRoute('PATCH', 'mailbox/\\d+'):
     $mailbox = new Mailbox($db, $user);
     httpResponse($mailbox->update((int) $params[1], $postdata));
     break;
 case validateRoute('POST', 'mailbox'):
     $mailbox = new Mailbox($db, $user);
     httpResponse($mailbox->create($postdata));
     break;
 case validateRoute('DELETE', 'mailbox/\\d+'):
     $mailbox = new Mailbox($db, $user);
     httpResponse($mailbox->delete((int) $params[1]));
     break;
 case validateRoute('GET', 'moviedata/\\d+'):
     $movieData = new MovieData($db);
     httpResponse($movieData->getData($params[1]));
     break;
 case validateRoute('GET', 'moviedata/\\d+/refresh'):
     $movieData = new MovieData($db);
     httpResponse($movieData->updateImdbInfo($params[1]));
     break;
 case validateRoute('GET', 'moviedata/search'):
     $movieData = new MovieData($db);
     httpResponse($movieData->search($_GET["search"]));
     break;
 case validateRoute('GET', 'moviedata/imdb/\\w+'):
示例#11
0
文件: Domain.php 项目: ajaboa/crmpuan
 public function getSumMailboxes()
 {
     $record = Mailbox::model()->find(\GO\Base\Db\FindParams::newInstance()->single()->select('COUNT(*) AS count')->criteria(\GO\Base\Db\FindCriteria::newInstance()->addCondition('domain_id', $this->id)));
     return $record->count;
 }
function sendTestMail($amount = 0)
{
    global $RESPONSE;
    $account = Mailbox::GetById($_POST["p_mailbox"]);
    try {
        if ($account->Type == "IMAP" || $account->Type == "POP") {
            $reload = false;
            $amount = downloadFromMailbox($reload, $account->Type, $account->Host, $account->Port, $account->Password, $account->Username, $account->SSL, false, true);
            $return = 1;
        } else {
            $return = sendMail($account, $account->Email, $account->Email, "LiveZilla Test Mail", "LiveZilla Test Mail", true);
        }
    } catch (Exception $e) {
        logit(serialize($e));
        $return = $e->getMessage();
    }
    if (is_array($amount)) {
        $amount = count($amount);
    }
    if ($return == 1) {
        $RESPONSE->SetStandardResponse(1, base64_encode($amount));
    } else {
        $RESPONSE->SetStandardResponse(2, base64_encode($return));
    }
}
示例#13
0
 public function update($userId, $userData)
 {
     if ($this->getId() !== $userId && $this->getClass() < self::CLASS_ADMIN) {
         throw new Exception('Du har inte rättigheter att redigera denna användaren.', 401);
     }
     $sth = $this->db->prepare('SELECT * FROM users WHERE id = ?');
     $sth->bindParam(1, $userId, PDO::PARAM_INT);
     $sth->execute();
     $user = $sth->fetch(PDO::FETCH_ASSOC);
     if (!$user) {
         throw new Exception('Användaren finns inte.', 404);
     }
     $changedPassword = false;
     if ($userData["password"] != "") {
         if ($userData["password"] != $userData["passwordRepeat"]) {
             throw new Exception('Nytt lösenord och upprepade lösenordet stämmmer inte.');
         }
         if ($this->getClass() >= self::CLASS_ADMIN || $this->hashPassword($userData["previousPassword"], $user["added"]) == $user["passhash"]) {
             $userData["passhash"] = $this->hashPassword($userData["password"], $user["added"]);
             $changedPassword = true;
         } else {
             throw new Exception('Nuvarande lösenord är felaktigt.');
         }
     } else {
         $userData["passhash"] = $user["passhash"];
     }
     $userData["notifs"] = implode(",", $userData["notifs"]);
     $userData["warneduntil"] = $user["warneduntil"];
     // Only uploaders and above can use user class mask feature
     if ($this->getClass() < User::CLASS_UPLOADER) {
         $userData["doljuploader"] = $user["doljuploader"];
     }
     if ($this->getClass() >= User::CLASS_ADMIN) {
         $adminlogs = new AdminLogs($this->db, $this);
         $mailbox = new Mailbox($this->db);
         if ($user["enabled"] != $userData["enabled"]) {
             if ($userData["enabled"] == "yes") {
                 $adminlogs->create("{{username}} aktiverade kontot [url=/user/" . $user["id"] . "/" . $user["username"] . "][b]" . $user["username"] . "[/b][/url]");
                 $userData["modcomment"] = $this->appendAdminComments($userData["modcomment"], 'Kontot aktiverat ' . $this->getUsername());
             } else {
                 $adminlogs->create("{{username}} inaktiverade kontot [url=/user/" . $user["id"] . "/" . $user["username"] . "][b]" . $user["username"] . "[/b][/url] med anledning: [i]" . $userData["secret"] . "[/i]");
                 $userData["modcomment"] = $this->appendAdminComments($userData["modcomment"], 'Kontot inaktiverat utav ' . $this->getUsername() . ' med anledning: ' . $userData["secret"]);
             }
         }
         if ($user["class"] != $userData["class"]) {
             if ($user["class"] < $userData["class"]) {
                 $statusChange = "uppgraderad";
             } else {
                 $statusChange = "nedgraderad";
             }
             $newClass = Helper::getUserClassById($userData["class"]);
             $oldClass = Helper::getUserClassById($user["class"]);
             $mailbox->sendSystemMessage($user["id"], ucfirst($statusChange) . " till " . $newClass . "!", "Du har blivit " . $statusChange . " till statusnivån [b]" . $newClass . "[/b] utav en administratör.");
             $userData["modcomment"] = $this->appendAdminComments($userData["modcomment"], ucfirst($statusChange) . ' från ' . $oldClass . ' till ' . $newClass . ' utav ' . $this->getUsername());
             $adminlogs->create("{{username}} " . $statusChange . "e [url=/user/" . $user["id"] . "/" . $user["username"] . "][b]" . $user["username"] . "[/b][/url] från [b]" . $oldClass . "[/b] till [b]" . $newClass . "[/b].");
             $userData["doljuploader"] = $userData["class"];
             if ($userData["class"] >= self::CLASS_UPLOADER) {
                 $this->db->query('DELETE FROM iplog WHERE userid = ' . $user["id"]);
             }
         }
         if ($user["passkey"] != $userData["passkey"]) {
             $userData["modcomment"] = $this->appendAdminComments($userData["modcomment"], 'Passkey förnyad utav ' . $this->getUsername());
         }
         if ($user["warned"] != $userData["warned"]) {
             if ($userData["warned"] == "yes") {
                 $days = max(1, $userData["warnDays"]);
                 $userData["warneduntil"] = date("Y-m-d H:i:s", time() + 86400 * $days);
                 $userData["modcomment"] = $this->appendAdminComments($userData["modcomment"], 'Varnad i ' . $days . ' dagar utav ' . $this->getUsername() . ' med anledning: ' . $userData["warnReason"]);
                 $adminlogs->create("{{username}} varnade [url=/user/" . $user["id"] . "/" . $user["username"] . "][b]" . $user["username"] . "[/b][/url] i [b]" . $days . " dagar[/b] med anledning: [i]" . $userData["warnReason"] . "[/i]");
                 $mailbox->sendSystemMessage($user["id"], "Du är varnad!", "Du har mottagit en varning på [b]" . $days . " dagar[/b] utav en administratör.\n\nAnledning: [b]" . $userData["warnReason"] . "[/b]");
             } else {
                 $userData["warneduntil"] = "0000-00-00 00:00:00";
                 $userData["modcomment"] = $this->appendAdminComments($userData["modcomment"], 'Varning borttagen utav ' . $this->getUsername());
                 $adminlogs->create("{{username}} plockade bort varningen ifrån [url=/user/" . $user["id"] . "/" . $user["username"] . "][b]" . $user["username"] . "[/b][/url]");
                 $mailbox->sendSystemMessage($user["id"], "Varning borttagen", "Din varning har blivit borttagen utav en administratör.");
             }
         }
         if ($user["uploadban"] != $userData["uploadban"]) {
             if ($userData["uploadban"] == 1) {
                 $adminlogs->create("{{username}} uploadbannade [url=/user/" . $user["id"] . "/" . $user["username"] . "][b]" . $user["username"] . "[/b][/url]");
                 $userData["modcomment"] = $this->appendAdminComments($userData["modcomment"], 'Uploadbannad utav ' . $this->getUsername());
             } else {
                 $adminlogs->create("{{username}} tog bort uploadban ifrån [url=/user/" . $user["id"] . "/" . $user["username"] . "][b]" . $user["username"] . "[/b][/url]");
                 $userData["modcomment"] = $this->appendAdminComments($userData["modcomment"], 'Uploadban borttagen utav ' . $this->getUsername());
             }
         }
         if ($user["inviteban"] != $userData["inviteban"]) {
             if ($userData["inviteban"] == 1) {
                 $adminlogs->create("{{username}} invitebannade [url=/user/" . $user["id"] . "/" . $user["username"] . "][b]" . $user["username"] . "[/b][/url]");
                 $userData["modcomment"] = $this->appendAdminComments($userData["modcomment"], 'Invitebannad utav ' . $this->getUsername());
             } else {
                 $adminlogs->create("{{username}} tog bort inviteban ifrån [url=/user/" . $user["id"] . "/" . $user["username"] . "][b]" . $user["username"] . "[/b][/url]");
                 $userData["modcomment"] = $this->appendAdminComments($userData["modcomment"], 'Inviteban borttagen utav ' . $this->getUsername());
             }
         }
         if ($user["forumban"] != $userData["forumban"]) {
             if ($userData["forumban"] == 1) {
                 $adminlogs->create("{{username}} forumbannade [url=/user/" . $user["id"] . "/" . $user["username"] . "][b]" . $user["username"] . "[/b][/url]");
                 $userData["modcomment"] = $this->appendAdminComments($userData["modcomment"], 'Forumbannad utav ' . $this->getUsername());
             } else {
                 $adminlogs->create("{{username}} tog bort forumban ifrån [url=/user/" . $user["id"] . "/" . $user["username"] . "][b]" . $user["username"] . "[/b][/url]");
                 $userData["modcomment"] = $this->appendAdminComments($userData["modcomment"], 'Forumban borttagen utav ' . $this->getUsername());
             }
         }
         if ($user["email"] != $userData["email"]) {
             $userData["modcomment"] = $this->appendAdminComments($userData["modcomment"], "Emailbyte från " . $user["email"] . " till " . $userData["email"] . " av " . $this->getUsername());
             $this->addEmailLog($user["id"], $user["email"]);
         }
         if ($user["username"] != $userData["username"]) {
             $adminlogs->create("{{username}} bytte nick på [url=/user/" . $user["id"] . "/" . $user["username"] . "][b]" . $user["username"] . "[/b][/url] till [url=/user/" . $user["id"] . "/" . $userData["username"] . "][b]" . $userData["username"] . "[/b][/url]");
             $userData["modcomment"] = $this->appendAdminComments($userData["modcomment"], "Nickbyte från " . $user["username"] . " till " . $userData["username"] . " av " . $this->getUsername());
         }
     }
     if ($this->getClass() >= User::CLASS_ADMIN) {
         $sth = $this->db->prepare("UPDATE users SET avatar = :avatar, gender = :gender, parkerad = :parkerad, alder = :alder, info = :info, mbitupp = :mbitupp, mbitner = :mbitner, isp = :isp, anonym = :anonym, anonymratio = :anonymratio, anonymicons = :anonymicons, acceptpms = :acceptpms, tvvy = :tvvy, https = :https, notifs = :notifs, avatars = :avatars, torrentsperpage = :torrentsperpage, topicsperpage = :topicsperpage, postsperpage = :postsperpage, visagammalt = :visagammalt, passhash = :passhash, design = :design, css = :css, search_sort = :search_sort, doljuploader = :doljuploader, leechstart = :leechstart, invites = :invites, reqslots = :reqslots, forumban = :forumban, inviteban = :inviteban, uploadban = :uploadban, passkey = :passkey, warneduntil = :warneduntil, warned = :warned, username = :username, enabled = :enabled, bonuspoang = :bonuspoang, donor = :donor, downloaded = :downloaded, uploaded = :uploaded, title = :title, modcomment = :modcomment, email = :email, secret = :secret, class = :class, invited_by = :invited_by WHERE id = :userId");
     } else {
         $sth = $this->db->prepare("UPDATE users SET avatar = :avatar, gender = :gender, parkerad = :parkerad, alder = :alder, info = :info, mbitupp = :mbitupp, mbitner = :mbitner, isp = :isp, anonym = :anonym, anonymratio = :anonymratio, anonymicons = :anonymicons, acceptpms = :acceptpms, tvvy = :tvvy, https = :https, notifs = :notifs, avatars = :avatars, torrentsperpage = :torrentsperpage, topicsperpage = :topicsperpage, postsperpage = :postsperpage, visagammalt = :visagammalt, passhash = :passhash, design = :design, css = :css, search_sort = :search_sort, doljuploader = :doljuploader WHERE id = :userId");
     }
     if ($this->getClass() >= User::CLASS_ADMIN) {
         $sth->bindParam(":leechstart", $userData["leechstart"], PDO::PARAM_STR);
         $sth->bindParam(":invites", $userData["invites"], PDO::PARAM_INT);
         $sth->bindParam(":reqslots", $userData["reqslots"], PDO::PARAM_INT);
         $sth->bindParam(":forumban", $userData["forumban"], PDO::PARAM_INT);
         $sth->bindParam(":inviteban", $userData["inviteban"], PDO::PARAM_INT);
         $sth->bindParam(":uploadban", $userData["uploadban"], PDO::PARAM_INT);
         $sth->bindParam(":passkey", $userData["passkey"], PDO::PARAM_STR);
         $sth->bindParam(":warned", $userData["warned"], PDO::PARAM_STR);
         $sth->bindParam(":warneduntil", $userData["warned"], PDO::PARAM_STR);
         $sth->bindParam(":username", $userData["username"], PDO::PARAM_STR);
         $sth->bindParam(":enabled", $userData["enabled"], PDO::PARAM_STR);
         $sth->bindParam(":bonuspoang", $userData["bonuspoang"], PDO::PARAM_INT);
         $sth->bindParam(":donor", $userData["donor"], PDO::PARAM_STR);
         $sth->bindParam(":downloaded", $userData["downloaded"], PDO::PARAM_INT);
         $sth->bindParam(":uploaded", $userData["uploaded"], PDO::PARAM_INT);
         $sth->bindParam(":title", $userData["title"], PDO::PARAM_STR);
         $sth->bindParam(":modcomment", $userData["modcomment"], PDO::PARAM_STR);
         $sth->bindParam(":email", $userData["email"], PDO::PARAM_STR);
         $sth->bindParam(":secret", $userData["secret"], PDO::PARAM_STR);
         $sth->bindParam(":class", $userData["class"], PDO::PARAM_STR);
         $sth->bindParam(":invited_by", $userData["invited_by"], PDO::PARAM_INT);
     }
     $sth->bindParam(":avatar", $userData["avatar"], PDO::PARAM_STR);
     $sth->bindParam(":gender", $userData["gender"], PDO::PARAM_INT);
     $sth->bindParam(":parkerad", $userData["parkerad"], PDO::PARAM_INT);
     $sth->bindParam(":alder", $userData["alder"], PDO::PARAM_INT);
     $sth->bindParam(":info", $userData["info"], PDO::PARAM_STR);
     $sth->bindParam(":mbitupp", $userData["mbitupp"], PDO::PARAM_STR);
     $sth->bindParam(":mbitner", $userData["mbitner"], PDO::PARAM_STR);
     $sth->bindParam(":isp", $userData["isp"], PDO::PARAM_STR);
     $sth->bindParam(":anonym", $userData["anonym"], PDO::PARAM_STR);
     $sth->bindParam(":anonymratio", $userData["anonymratio"], PDO::PARAM_STR);
     $sth->bindParam(":anonymicons", $userData["anonymicons"], PDO::PARAM_STR);
     $sth->bindParam(":acceptpms", $userData["acceptpms"], PDO::PARAM_STR);
     $sth->bindParam(":tvvy", $userData["tvvy"], PDO::PARAM_INT);
     $sth->bindParam(":https", $userData["https"], PDO::PARAM_INT);
     $sth->bindParam(":notifs", $userData["notifs"], PDO::PARAM_STR);
     $sth->bindParam(":avatars", $userData["avatars"], PDO::PARAM_STR);
     $sth->bindParam(":torrentsperpage", $userData["torrentsperpage"], PDO::PARAM_INT);
     $sth->bindParam(":topicsperpage", $userData["topicsperpage"], PDO::PARAM_INT);
     $sth->bindParam(":postsperpage", $userData["postsperpage"], PDO::PARAM_INT);
     $sth->bindParam(":visagammalt", $userData["visagammalt"], PDO::PARAM_INT);
     $sth->bindParam(":passhash", $userData["passhash"], PDO::PARAM_STR);
     $sth->bindParam(":design", $userData["design"], PDO::PARAM_INT);
     $sth->bindParam(":css", $userData["css"], PDO::PARAM_STR);
     $sth->bindParam(":search_sort", $userData["search_sort"], PDO::PARAM_STR);
     $sth->bindParam(":doljuploader", $userData["doljuploader"], PDO::PARAM_INT);
     $sth->bindParam(":userId", $userId, PDO::PARAM_INT);
     $sth->execute();
     if ($changedPassword && $this->getId() == $userId) {
         $this->login($user["username"], $userData["password"], $_COOKIE["notuseip"] == "true");
     }
 }
示例#14
0
 public function update($userId, $userData)
 {
     if ($this->getId() !== $userId && $this->getClass() < self::CLASS_ADMIN) {
         throw new Exception(L::get("PERMISSION_DENIED"), 401);
     }
     $sth = $this->db->prepare('SELECT * FROM users WHERE id = ?');
     $sth->bindParam(1, $userId, PDO::PARAM_INT);
     $sth->execute();
     $user = $sth->fetch(PDO::FETCH_ASSOC);
     if (!$user) {
         throw new Exception(L::get("USER_NOT_EXIST"), 404);
     }
     $changedPassword = false;
     if ($userData["password"] != "") {
         if ($userData["password"] != $userData["passwordRepeat"]) {
             throw new Exception(L::get("NEW_PASSWORD_NOT_MATCHING"));
         }
         if ($this->getClass() >= self::CLASS_ADMIN || password_verify($userData["previousPassword"] . User::PASSWORD_SALT, $user["passhash"])) {
             $userData["passhash"] = $this->hashPassword($userData["password"], $user["added"]);
             $changedPassword = true;
         } else {
             throw new Exception(L::get("CURRENT_PASSWORD_WRONG"));
         }
     } else {
         $userData["passhash"] = $user["passhash"];
     }
     $userData["notifs"] = implode(",", $userData["notifs"]);
     $userData["warneduntil"] = $user["warneduntil"];
     if (!in_array($userData["language"], Config::$languages)) {
         $userData["language"] = Config::DEFAULT_LANGUAGE;
     }
     // Only uploaders and above can use user class mask feature
     if ($this->getClass() < User::CLASS_UPLOADER) {
         $userData["doljuploader"] = $user["doljuploader"];
     }
     if ($this->getClass() >= User::CLASS_ADMIN) {
         $adminlogs = new AdminLogs($this->db, $this);
         $mailbox = new Mailbox($this->db);
         if ($user["enabled"] != $userData["enabled"]) {
             if ($userData["enabled"] == "yes") {
                 $adminlogs->create(L::get("ACCOUNT_ACTIVATED_ADMIN_LOG", [$user["id"], $user["username"], $user["username"]], Config::DEFAULT_LANGUAGE));
                 $userData["modcomment"] = $this->appendAdminComments($userData["modcomment"], L::get("ACCOUNT_ACTIVATED_LOG", [$this->getUsername()], Config::DEFAULT_LANGUAGE));
             } else {
                 $adminlogs->create(L::get("ACCOUNT_DEACTIVATED_ADMIN_LOG", [$user["id"], $user["username"], $user["username"], $userData["secret"]], Config::DEFAULT_LANGUAGE));
                 $userData["modcomment"] = $this->appendAdminComments($userData["modcomment"], L::get("ACCOUNT_DEACTIVATED_LOG", [$this->getUsername(), $userData["secret"]], Config::DEFAULT_LANGUAGE));
             }
         }
         if ($user["class"] != $userData["class"]) {
             if ($user["class"] < $userData["class"]) {
                 $statusChangeUser = L::get("STATUS_UPGRADED", null, $user["language"]);
                 $statusChangeLog = L::get("STATUS_UPGRADED", null, Config::DEFAULT_LANGUAGE);
                 $statusChangeTense = L::get("STATUS_WAS_UPGRADED", null, Config::DEFAULT_LANGUAGE);
             } else {
                 $statusChangeUser = L::get("STATUS_DOWNGRADED", null, $user["language"]);
                 $statusChangeLog = L::get("STATUS_DOWNGRADED", null, Config::DEFAULT_LANGUAGE);
                 $statusChangeTense = L::get("STATUS_WAS_DOWNGRADED", null, Config::DEFAULT_LANGUAGE);
             }
             $newClass = Helper::getUserClassById($userData["class"]);
             $oldClass = Helper::getUserClassById($user["class"]);
             $mailbox->sendSystemMessage($user["id"], L::get("CLASS_CHANGED_SUBJECT", [ucfirst($statusChangeUser), $newClass], $user["language"]), L::get("CLASS_CHANGED_MESSAGE", [$statusChangeUser, $newClass], $user["language"]));
             $userData["modcomment"] = $this->appendAdminComments($userData["modcomment"], L::get("CLASS_CHANGED_COMMENT", [ucfirst($statusChangeLog), $oldClass, $newClass, $this->getUsername()], Config::DEFAULT_LANGUAGE));
             $adminlogs->create(L::get("CLASS_CHANGED_ADMINLOG", [$statusChangeTense, $user["id"], $user["username"], $user["username"], $oldClass, $newClass], Config::DEFAULT_LANGUAGE));
             $userData["doljuploader"] = $userData["class"];
             if ($userData["class"] >= self::CLASS_MOVIE_STAR) {
                 $this->db->query('DELETE FROM iplog WHERE userid = ' . $user["id"]);
             }
         }
         if ($user["passkey"] != $userData["passkey"]) {
             $userData["modcomment"] = $this->appendAdminComments($userData["modcomment"], L::get("PASSKEY_RENEWED", [$this->getUsername()], Config::DEFAULT_LANGUAGE));
         }
         if ($user["warned"] != $userData["warned"]) {
             if ($userData["warned"] == "yes") {
                 $days = max(1, $userData["warnDays"]);
                 $userData["warneduntil"] = date("Y-m-d H:i:s", time() + 86400 * $days);
                 $userData["modcomment"] = $this->appendAdminComments($userData["modcomment"], L::get("WARNED_USERLOG", [$days, $this->getUsername(), $userData["warnReason"]], Config::DEFAULT_LANGUAGE));
                 $adminlogs->create(L::get("WARNED_ADMINLOG", [$user["id"], $user["username"], $user["username"], $days, $userData["warnReason"]], Config::DEFAULT_LANGUAGE));
                 $mailbox->sendSystemMessage($user["id"], L::get("WARNED_PM_SUBJECT", null, $user["language"]), L::get("WARNED_PM_BODY", [$days, $userData["warnReason"]], $user["language"]));
             } else {
                 $userData["warneduntil"] = "0000-00-00 00:00:00";
                 $userData["modcomment"] = $this->appendAdminComments($userData["modcomment"], L::get("WARNING_REMOVED_USERLOG", [$this->getUsername()]));
                 $adminlogs->create(L::get("WARNING_REMOVED_ADMINLOG", [$user["id"], $user["username"], $user["username"]], Config::DEFAULT_LANGUAGE));
                 $mailbox->sendSystemMessage($user["id"], L::get("WARNING_REMOVED_PM_SUBJECT", null, $user["language"]), L::get("WARNING_REMOVED_PM_BODY", null, $user["language"]));
             }
         }
         if ($user["uploadban"] != $userData["uploadban"]) {
             if ($userData["uploadban"] == 1) {
                 $adminlogs->create(L::get("UPLOADBAN_ADDED", [$user["id"], $user["username"], $user["username"]], Config::DEFAULT_LANGUAGE));
                 $userData["modcomment"] = $this->appendAdminComments($userData["modcomment"], L::get("UPLOADBAN_ADDED_LOG", [$this->getUsername()], Config::DEFAULT_LANGUAGE));
             } else {
                 $adminlogs->create(L::get("UPLOADBAN_REMOVED", [$user["id"], $user["username"], $user["username"]], Config::DEFAULT_LANGUAGE));
                 $userData["modcomment"] = $this->appendAdminComments($userData["modcomment"], L::get("UPLOADBAN_REMOVED_LOG", [$this->getUsername()], Config::DEFAULT_LANGUAGE));
             }
         }
         if ($user["inviteban"] != $userData["inviteban"]) {
             if ($userData["inviteban"] == 1) {
                 $adminlogs->create(L::get("INVITEBAN_ADDED", [$user["id"], $user["username"], $user["username"]], Config::DEFAULT_LANGUAGE));
                 $userData["modcomment"] = $this->appendAdminComments($userData["modcomment"], L::get("INVITEBAN_ADDED_LOG", [$this->getUsername()], Config::DEFAULT_LANGUAGE));
             } else {
                 $adminlogs->create(L::get("INVITEBAN_REMOVED", [$user["id"], $user["username"], $user["username"]], Config::DEFAULT_LANGUAGE));
                 $userData["modcomment"] = $this->appendAdminComments($userData["modcomment"], L::get("INVITEBAN_REMOVED_LOG", [$this->getUsername()], Config::DEFAULT_LANGUAGE));
             }
         }
         if ($user["forumban"] != $userData["forumban"]) {
             if ($userData["forumban"] == 1) {
                 $adminlogs->create(L::get("FORUMBAN_ADDED", [$user["id"], $user["username"], $user["username"]], Config::DEFAULT_LANGUAGE));
                 $userData["modcomment"] = $this->appendAdminComments($userData["modcomment"], L::get("FORUM_BANNED_BY", [$this->getUsername()], Config::DEFAULT_LANGUAGE));
             } else {
                 $adminlogs->create(L::get("FORUMBAN_REMOVED", [$user["id"], $user["username"], $user["username"]], Config::DEFAULT_LANGUAGE));
                 $userData["modcomment"] = $this->appendAdminComments($userData["modcomment"], L::get("FORUM_UNBANNED_BY", [$this->getUsername()], Config::DEFAULT_LANGUAGE));
             }
         }
         if ($this->hashEmail($user["email"]) != $this->hashEmail($userData["email"])) {
             $userData["modcomment"] = $this->appendAdminComments($userData["modcomment"], L::get("EMAIL_CHANGE_LOG", [$this->hashEmail($user["email"]), $this->hashEmail($userData["email"]), $this->getUsername()], Config::DEFAULT_LANGUAGE));
             $this->addEmailLog($user["id"], $this->hashEmail($user["email"]));
         }
         if ($user["username"] != $userData["username"]) {
             $adminlogs->create(L::get("USERNAME_CHANGE_LOG", [$user["id"], $user["username"], $user["username"], $user["id"], $userData["username"], $userData["username"]], Config::DEFAULT_LANGUAGE));
             $userData["modcomment"] = $this->appendAdminComments($userData["modcomment"], L::get("USERNAME_CHANGE_ADMIN_LOG", [$user["username"], $userData["username"], $this->getUsername()], Config::DEFAULT_LANGUAGE));
         }
     }
     if ($this->getClass() >= User::CLASS_ADMIN) {
         $sth = $this->db->prepare("UPDATE users SET avatar = :avatar, gender = :gender, parkerad = :parkerad, alder = :alder, info = :info, mbitupp = :mbitupp, mbitner = :mbitner, isp = :isp, anonym = :anonym, anonymratio = :anonymratio, anonymicons = :anonymicons, acceptpms = :acceptpms, tvvy = :tvvy, https = :https, notifs = :notifs, avatars = :avatars, torrentsperpage = :torrentsperpage, topicsperpage = :topicsperpage, postsperpage = :postsperpage, passhash = :passhash, design = :design, css = :css, search_sort = :search_sort, doljuploader = :doljuploader, leechstart = :leechstart, invites = :invites, reqslots = :reqslots, forumban = :forumban, inviteban = :inviteban, uploadban = :uploadban, passkey = :passkey, warneduntil = :warneduntil, warned = :warned, username = :username, enabled = :enabled, bonuspoang = :bonuspoang, donor = :donor, downloaded = :downloaded, uploaded = :uploaded, title = :title, modcomment = :modcomment, email = :email, secret = :secret, class = :class, invited_by = :invited_by, section = :section, p2p = :p2p, language = :language WHERE id = :userId");
     } else {
         $sth = $this->db->prepare("UPDATE users SET avatar = :avatar, gender = :gender, parkerad = :parkerad, alder = :alder, info = :info, mbitupp = :mbitupp, mbitner = :mbitner, isp = :isp, anonym = :anonym, anonymratio = :anonymratio, anonymicons = :anonymicons, acceptpms = :acceptpms, tvvy = :tvvy, https = :https, notifs = :notifs, avatars = :avatars, torrentsperpage = :torrentsperpage, topicsperpage = :topicsperpage, postsperpage = :postsperpage, passhash = :passhash, design = :design, css = :css, search_sort = :search_sort, doljuploader = :doljuploader, section = :section, p2p = :p2p, language = :language WHERE id = :userId");
     }
     if ($this->getClass() >= User::CLASS_ADMIN) {
         $sth->bindParam(":leechstart", $userData["leechstart"], PDO::PARAM_STR);
         $sth->bindParam(":invites", $userData["invites"], PDO::PARAM_INT);
         $sth->bindParam(":reqslots", $userData["reqslots"], PDO::PARAM_INT);
         $sth->bindParam(":forumban", $userData["forumban"], PDO::PARAM_INT);
         $sth->bindParam(":inviteban", $userData["inviteban"], PDO::PARAM_INT);
         $sth->bindParam(":uploadban", $userData["uploadban"], PDO::PARAM_INT);
         $sth->bindParam(":passkey", $userData["passkey"], PDO::PARAM_STR);
         $sth->bindParam(":warned", $userData["warned"], PDO::PARAM_STR);
         $sth->bindParam(":warneduntil", $userData["warned"], PDO::PARAM_STR);
         $sth->bindParam(":username", $userData["username"], PDO::PARAM_STR);
         $sth->bindParam(":enabled", $userData["enabled"], PDO::PARAM_STR);
         $sth->bindParam(":bonuspoang", $userData["bonuspoang"], PDO::PARAM_INT);
         $sth->bindParam(":donor", $userData["donor"], PDO::PARAM_STR);
         $sth->bindParam(":downloaded", $userData["downloaded"], PDO::PARAM_INT);
         $sth->bindParam(":uploaded", $userData["uploaded"], PDO::PARAM_INT);
         $sth->bindParam(":title", $userData["title"], PDO::PARAM_STR);
         $sth->bindParam(":modcomment", $userData["modcomment"], PDO::PARAM_STR);
         $sth->bindValue(":email", $this->hashEmail($userData["email"]), PDO::PARAM_STR);
         $sth->bindParam(":secret", $userData["secret"], PDO::PARAM_STR);
         $sth->bindParam(":class", $userData["class"], PDO::PARAM_STR);
         $sth->bindParam(":invited_by", $userData["invited_by"], PDO::PARAM_INT);
     }
     $sth->bindParam(":avatar", $userData["avatar"], PDO::PARAM_STR);
     $sth->bindParam(":gender", $userData["gender"], PDO::PARAM_INT);
     $sth->bindParam(":parkerad", $userData["parkerad"], PDO::PARAM_INT);
     $sth->bindParam(":alder", $userData["alder"], PDO::PARAM_INT);
     $sth->bindParam(":info", $userData["info"], PDO::PARAM_STR);
     $sth->bindParam(":mbitupp", $userData["mbitupp"], PDO::PARAM_STR);
     $sth->bindParam(":mbitner", $userData["mbitner"], PDO::PARAM_STR);
     $sth->bindParam(":isp", $userData["isp"], PDO::PARAM_STR);
     $sth->bindParam(":anonym", $userData["anonym"], PDO::PARAM_STR);
     $sth->bindParam(":anonymratio", $userData["anonymratio"], PDO::PARAM_STR);
     $sth->bindParam(":anonymicons", $userData["anonymicons"], PDO::PARAM_STR);
     $sth->bindParam(":acceptpms", $userData["acceptpms"], PDO::PARAM_STR);
     $sth->bindParam(":tvvy", $userData["tvvy"], PDO::PARAM_INT);
     $sth->bindParam(":https", $userData["https"], PDO::PARAM_INT);
     $sth->bindParam(":notifs", $userData["notifs"], PDO::PARAM_STR);
     $sth->bindParam(":avatars", $userData["avatars"], PDO::PARAM_STR);
     $sth->bindParam(":torrentsperpage", $userData["torrentsperpage"], PDO::PARAM_INT);
     $sth->bindParam(":topicsperpage", $userData["topicsperpage"], PDO::PARAM_INT);
     $sth->bindParam(":postsperpage", $userData["postsperpage"], PDO::PARAM_INT);
     $sth->bindParam(":passhash", $userData["passhash"], PDO::PARAM_STR);
     $sth->bindParam(":design", $userData["design"], PDO::PARAM_INT);
     $sth->bindParam(":css", $userData["css"], PDO::PARAM_STR);
     $sth->bindParam(":search_sort", $userData["search_sort"], PDO::PARAM_STR);
     $sth->bindParam(":doljuploader", $userData["doljuploader"], PDO::PARAM_INT);
     $sth->bindParam(":section", $userData["section"], PDO::PARAM_STR);
     $sth->bindParam(":p2p", $userData["p2p"], PDO::PARAM_INT);
     $sth->bindParam(":language", $userData["language"], PDO::PARAM_STR);
     $sth->bindParam(":userId", $userId, PDO::PARAM_INT);
     $sth->execute();
     if ($changedPassword && $this->getId() == $userId) {
         $this->login($user["username"], $userData["password"]);
     }
 }
示例#15
0
 public static function model($className = __CLASS__)
 {
     return parent::model($className);
 }
示例#16
0
/**
 * @brief get user personal messages
 * @global type $uid
 * @global type $urlServer
 * @global type $langFrom
 * @global type $dateFormatLong
 * @param type $lesson_id
 * @return string
 */
function getUserMessages() {
           
    global $uid, $urlServer, $langFrom, $dateFormatLong;
    
    $message_content = '';    
               
    $mbox = new Mailbox($uid, 0);
    $msgs = $mbox->getInboxMsgs('', 5);
    foreach ($msgs as $message) {
        if ($message->course_id > 0) {
            $course_title = q(ellipsize(course_id_to_title($message->course_id), 30));
        } else {
            $course_title = '';
        }
        $message_date = claro_format_locale_date($dateFormatLong, $message->timestamp);
        $message_content .= "<li class='list-item'>
                                <div class='item-wholeline'>                                    
                                    <div class='text-title'>$langFrom ".display_user($message->author_id, false, false).":
                                        <a href='{$urlServer}modules/dropbox/index.php?mid=$message->id'>" .q($message->subject)."</a>
                                    </div>                                    
                                    <div class='text-grey'>$course_title</div>
                                    <div>$message_date</div>
                                </div>
                            </li>";
    }    
    return $message_content;
}
示例#17
0
 public function actionUpdatemsg()
 {
     echo Mailbox::newMsgs(Yii::app()->user->id);
 }
function sendChatTranscripts($_custom = false)
{
    global $CONFIG, $INTERNAL, $GROUPS, $INPUTS;
    initData(array("INTERNAL", "INPUTS"));
    closeChats();
    $defmailbox = Mailbox::GetDefaultOutgoing();
    $result = queryDB(false, "SELECT `voucher_id`,`subject`,`customs`,`internal_id`,`transcript_text`,`transcript_receiver`,`email`,`chat_id`,`fullname`,`group_id` FROM `" . DB_PREFIX . DATABASE_CHAT_ARCHIVE . "` WHERE `chat_type`=1 AND `endtime`>0 AND `closed`>0 AND `transcript_sent`=0 LIMIT 1;");
    if ($result) {
        while ($row = DBManager::FetchArray($result)) {
            if (empty($row["transcript_text"])) {
                continue;
            }
            queryDB(true, "UPDATE `" . DB_PREFIX . DATABASE_CHAT_ARCHIVE . "` SET `transcript_sent`=1 WHERE `chat_id`='" . DBManager::RealEscape($row["chat_id"]) . "' LIMIT 1;");
            $rcvs = str_replace(array("%fullname%", "%efullname%"), $row["fullname"], $row["transcript_text"]);
            $rcvs = str_replace(array("%email%", "%eemail%"), $row["email"], $rcvs);
            $rcvs = str_replace("%rating%", getRatingAVGFromChatId($row["chat_id"]), $rcvs);
            $subject = $row["subject"];
            $customs = @unserialize($row["customs"]);
            $fakeSender = "";
            foreach ($INPUTS as $index => $input) {
                if ($input->Active && $input->Custom && !isset($GROUPS[$row["group_id"]]->TicketInputsHidden[$index])) {
                    $cv = "";
                    if ($input->Type == "CheckBox") {
                        $cv = !empty($customs[$input->Name]) ? "<!--lang_client_yes-->" : "<!--lang_client_no-->";
                    } else {
                        if (!empty($customs[$input->Name]) || $input->Type == "ComboBox") {
                            $cv = $input->GetClientValue(@$customs[$input->Name]);
                        }
                    }
                    $rcvs = str_replace("%custom" . $index . "%", $cv, $rcvs);
                }
            }
            $rcvs = applyReplacements($rcvs);
            $rcvs = Mailbox::FinalizeEmail($rcvs . "\r\n\r\n<!--lz_ref_link-->");
            $mailbox = null;
            if (!empty($row["group_id"]) && isset($GROUPS[$row["group_id"]]) && !empty($GROUPS[$row["group_id"]]->ChatEmailOut)) {
                $mailbox = Mailbox::GetById($GROUPS[$row["group_id"]]->ChatEmailOut);
            }
            $mailbox = !empty($mailbox) ? $mailbox : $defmailbox;
            if ((!empty($CONFIG["gl_soct"]) || $_custom) && !empty($row["transcript_receiver"])) {
                sendMail($mailbox, $row["transcript_receiver"], $mailbox->Email, $rcvs, $subject);
            }
            if (!empty($CONFIG["gl_scto"]) && !$_custom) {
                initData(array("INTERNAL"));
                $receivers = array();
                $resulti = queryDB(true, "SELECT `sender`,`receiver` FROM `" . DB_PREFIX . DATABASE_POSTS . "` WHERE `chat_id`='" . DBManager::RealEscape($row["chat_id"]) . "';");
                if ($resulti) {
                    while ($rowi = DBManager::FetchArray($resulti)) {
                        if (!empty($INTERNAL[$rowi["sender"]]) && !in_array($rowi["sender"], $receivers)) {
                            $receivers[] = $rowi["sender"];
                        } else {
                            if (!empty($INTERNAL[$rowi["receiver"]]) && !in_array($rowi["receiver"], $receivers)) {
                                $receivers[] = $rowi["receiver"];
                            } else {
                                continue;
                            }
                        }
                        sendMail($mailbox, $INTERNAL[$receivers[count($receivers) - 1]]->Email, $mailbox->Email, $rcvs, $subject);
                    }
                }
            }
            if (!empty($CONFIG["gl_sctg"]) && !$_custom) {
                initData(array("GROUPS"));
                sendMail($mailbox, $GROUPS[$row["group_id"]]->Email, $mailbox->Email, $rcvs, $subject);
            }
            if (!empty($mailbox) && !empty($CONFIG["gl_scct"])) {
                if (!empty($CONFIG["gl_uvec"])) {
                    if (Mailbox::IsValidEmail($row["transcript_receiver"])) {
                        $fakeSender = $row["transcript_receiver"];
                    } else {
                        if (Mailbox::IsValidEmail($row["email"])) {
                            $fakeSender = $row["email"];
                        }
                    }
                }
                sendMail($mailbox, $CONFIG["gl_scct"], $mailbox->Email, $rcvs, $subject, false, null, $fakeSender);
            }
            if (!empty($row["voucher_id"])) {
                $ticket = new CommercialChatVoucher(null, $row["voucher_id"]);
                $ticket->Load();
                $ticket->SendStatusEmail();
            }
        }
    }
    if (!empty($CONFIG["gl_rm_chats"]) && $CONFIG["gl_rm_chats_time"] == 0) {
        queryDB(true, "DELETE FROM `" . DB_PREFIX . DATABASE_CHAT_ARCHIVE . "` WHERE `transcript_sent` = '1';");
    }
}
 static function UpdateConfiguration($id = 0)
 {
     if (OperatorRequest::IsValidated() && Is::Defined("VALIDATED_FULL_LOGIN") && OperatorRequest::IsAdministrator(true)) {
         Logging::SecurityLog("ServerManager::UpdateConfiguration", "", CALLER_SYSTEM_ID);
         if (Is::Defined("STATS_ACTIVE") && !empty($_POST["p_reset_stats"])) {
             Server::$Statistic->ResetAll();
         }
         $int = 0;
         if (DB_CONNECTION) {
             DBManager::Execute(true, "UPDATE `" . DB_PREFIX . DATABASE_COMMERCIAL_CHAT_TYPES . "` SET `delete`='1';");
             DBManager::Execute(true, "DELETE FROM `" . DB_PREFIX . DATABASE_COMMERCIAL_CHAT_LOCALIZATIONS . "`;");
             while (!empty($_POST["p_cfg_cct_id_" . $int])) {
                 $cct = new CommercialChatBillingType($_POST["p_cfg_cct_id_" . $int], $_POST["p_cfg_cct_mnoc_" . $int], $_POST["p_cfg_cct_mtloc_" . $int], $_POST["p_cfg_cct_tae_" . $int], $_POST["p_cfg_cct_tvbo_" . $int], $_POST["p_cfg_cct_svbo_" . $int], $_POST["p_cfg_cct_evbo_" . $int], $_POST["p_cfg_cct_citl_" . $int], $_POST["p_cfg_cct_p_" . $int]);
                 $cct->Save();
                 $iint = 0;
                 while (!empty($_POST["p_cfg_cctli_id_" . $int . "_" . $iint])) {
                     $cctl = new CommercialChatVoucherLocalization($_POST["p_cfg_cctli_id_" . $int . "_" . $iint], $_POST["p_cfg_cctli_itl_" . $int . "_" . $iint], $_POST["p_cfg_cctli_t_" . $int . "_" . $iint], $_POST["p_cfg_cctli_d_" . $int . "_" . $iint], $_POST["p_cfg_cctli_terms_" . $int . "_" . $iint], $_POST["p_cfg_cctli_emvc_" . $int . "_" . $iint], $_POST["p_cfg_cctli_emvp_" . $int . "_" . $iint], $_POST["p_cfg_cctli_emvu_" . $int . "_" . $iint], $_POST["p_cfg_cctli_exr_" . $int . "_" . $iint]);
                     $cctl->Save($_POST["p_cfg_cct_id_" . $int]);
                     $iint++;
                 }
                 $int++;
             }
             $int = 0;
             DBManager::Execute(true, "DELETE FROM `" . DB_PREFIX . DATABASE_COMMERCIAL_CHAT_PROVIDERS . "`;");
             while (!empty($_POST["p_cfg_ccpp_id_" . $int])) {
                 $ccpp = new CommercialChatPaymentProvider($_POST["p_cfg_ccpp_id_" . $int], $_POST["p_cfg_ccpp_n_" . $int], $_POST["p_cfg_ccpp_a_" . $int], $_POST["p_cfg_ccpp_u_" . $int], $_POST["p_cfg_ccpp_l_" . $int]);
                 $ccpp->Save();
                 $int++;
             }
             $int = 0;
             DBManager::Execute(true, "DELETE FROM `" . DB_PREFIX . DATABASE_MAILBOXES . "`;");
             while (!empty($_POST["p_cfg_es_i_" . $int])) {
                 $acc = new Mailbox($int, true);
                 $acc->Save();
                 $int++;
             }
             $int = 0;
             DBManager::Execute(true, "DELETE FROM `" . DB_PREFIX . DATABASE_FEEDBACK_CRITERIA_CONFIG . "`;");
             while (isset($_POST["p_cfg_fc_i_" . $int])) {
                 $fc = new FeedbackCriteria($int, true);
                 $fc->Save();
                 $int++;
             }
             DBManager::Execute(true, "DELETE FROM `" . DB_PREFIX . DATABASE_COMMERCIAL_CHAT_TYPES . "` WHERE `delete`='1';");
             DBManager::Execute(true, "DELETE FROM `" . DB_PREFIX . DATABASE_CONFIG . "`;");
             foreach ($_POST as $key => $value) {
                 if (strpos($key, "p_cfg_g_") === 0) {
                     $skey = str_replace("p_cfg_g_", "", $key);
                     $value = base64_decode($value);
                     DBManager::Execute(true, "REPLACE INTO `" . DB_PREFIX . DATABASE_CONFIG . "` (`key`,`value`) VALUES ('" . DBManager::RealEscape($skey) . "','" . DBManager::RealEscape($value) . "');");
                 }
             }
             CacheManager::Flush();
         }
         if (isset($_POST["p_available"])) {
             ServerManager::UpdateAvailability(!empty($_POST["p_available"]));
         }
         //$id = IOStruct::CreateFile($file,base64_decode($_POST["p_upload_value"]),true);
     }
     GeoTracking::SpanRemove(true);
     CacheManager::Flush();
     Server::$Response->SetStandardResponse($id, "");
 }
 static function SendTicketAutoresponder($_ticket, $_language, $_customs = true, $details = "", $cv = "", $pdm = null)
 {
     global $INPUTS, $CONFIG, $GROUPS;
     $message = "%details%\r\n\r\n%mailtext%\r\n\r\n";
     $wordcount = str_words_count($message);
     if (!empty($GROUPS[$_ticket->Group]->PredefinedMessages)) {
         $pdm = getPredefinedMessage($GROUPS[$_ticket->Group]->PredefinedMessages, $_language);
         if (!empty($pdm->EmailTicket)) {
             $message = $pdm->EmailTicket;
         }
     }
     if ($INPUTS[111]->Active && !empty($_ticket->Messages[0]->Fullname)) {
         $details .= strip_tags($INPUTS[111]->Caption) . " " . $_ticket->Messages[0]->Fullname . "\r\n";
     }
     if (!empty($_ticket->Email)) {
         $details .= strip_tags($INPUTS[112]->Caption) . " " . $_ticket->Messages[0]->Email . "\r\n";
     }
     if ($INPUTS[113]->Active && !empty($_ticket->Messages[0]->Company)) {
         $details .= strip_tags($INPUTS[113]->Caption) . " " . $_ticket->Messages[0]->Company . "\r\n";
     }
     if (($INPUTS[116]->Active || $_ticket->Messages[0]->CallMeBack) && !empty($_ticket->Messages[0]->Phone)) {
         $details .= strip_tags($INPUTS[116]->Caption) . " " . $_ticket->Messages[0]->Phone . "\r\n";
     }
     $message = str_replace("%mailtext%", $_ticket->Messages[0]->Text, $message);
     $message = str_replace("%external_phone%", $_ticket->Messages[0]->Phone, $message);
     $message = str_replace("%external_name%", $_ticket->Messages[0]->Fullname, $message);
     $message = str_replace("%external_email%", $_ticket->Messages[0]->Email, $message);
     $message = str_replace("%website_name%", $CONFIG["gl_site_name"], $message);
     if ($_customs && ++$wordcount > 0) {
         foreach ($INPUTS as $index => $input) {
             if ($input->Active && $input->Custom && !isset($_ticket->Group->TicketInputsHidden[$index])) {
                 if ($input->Type == "CheckBox") {
                     $details .= strip_tags($input->Caption) . " " . ($cv = !empty($_ticket->Messages[0]->Customs[$index]) ? "<!--lang_client_yes-->" : "<!--lang_client_no-->") . "\r\n";
                 } else {
                     if (!empty($_ticket->Messages[0]->Customs[$index]) || $input->Type == "ComboBox") {
                         $details .= strip_tags($input->Caption) . " " . ($cv = $input->GetClientValue($_ticket->Messages[0]->Customs[$index])) . "\r\n";
                     }
                 }
                 $message = str_replace("%custom" . $index . "%", $cv, $message);
             }
         }
     }
     $message = str_replace("%localdate%", date("r"), $message);
     $message = str_replace(array("%group_name%", "%group_id%"), $_ticket->Group, $message);
     $message = str_replace("%group_description%", $GROUPS[$_ticket->Group]->GetDescription($_ticket->Language), $message);
     $message = str_replace("%details%", $details, $message);
     $message = str_replace("%external_ip%", getIP(), $message);
     $message = str_replace("%ticket_id%", $_ticket->Id, $message);
     $mailbox = Mailbox::GetDefaultOutgoing();
     $_ticket->SendAutoresponder($mailbox, applyReplacements($message), $pdm, array());
 }
示例#21
0
                <div class="header-right">
                	<div class="nav">
                      <ul class="nav-list">
                        <li><a href="#" class="nav-link orange"><i class="fa fa-bell"></i> <span class="nav-counter nav-counter-green">4</span></a></li>
                      <?php 
		    $empsession = 0;
		    $studsession = 0;
		    $count = 0;
		    if(!Yii::app()->user->isGuest){
		      $studsession = Yii::app()->user->getState('stud_id');
		      $empsession = Yii::app()->user->getState('emp_id');
		    }
		    if(!Yii::app()->user->isGuest && !Yii::app()->user->getState('parent_id'))
		    {
			$count = 0;
			$count = Mailbox::model()->newMsgs(Yii::app()->user->id);	
		     ?>
			<li><a href="<?php echo Yii::app()->baseUrl;?>/mailbox" class="nav-link green"><i class="fa fa-envelope"></i> <span class="nav-counter nav-counter-blue"><?php echo $count;?></span></a></li>
		   <?php			
		    }?>
                        <li><a href="#" class="nav-link orange"><i class="fa fa-tasks"></i> <span class="nav-counter nav-counter-green">15</span></a></li>
			<?php		
			$isStudent = Yii::app()->user->getState('stud_id');
			$isEmployee = Yii::app()->user->getState('emp_id');
			if(isset($isStudent))
			{
			  $stdinfo = StudentInfo::model()->findByAttributes(array('student_info_transaction_id'=>Yii::app()->user->getState('stud_id')));	
			  $stu_tran = StudentTransaction::model()->findByPk(Yii::app()->user->getState('stud_id'));
			  $stdpicPath = StudentPhotos::model()->findByPk($stu_tran->student_transaction_student_photos_id);
			  $stud_photo=Yii::app()->baseUrl."/college_data/stud_images/".$stdpicPath->student_photos_path;
			?>
示例#22
0
 */
Yii::import('application.modules.message.models.*');
?>

<table class="detail-view">
	
	<tbody>
		
		<tr>
			<th><?php 
echo Yii::t('app', 'webserver');
?>
</th>
			<td><?php 
echo $_SERVER['SERVER_SOFTWARE'];
?>
</td>
		</tr>
		<tr>
			<th><?php 
echo Yii::t('app', 'new messages');
?>
</th>
			<td><?php 
echo Mailbox::newMsgs(Yii::app()->user->id);
?>
</td>
		</tr>
	</tbody>
</table>
 function SendStatusEmail()
 {
     Server::InitDataBlock(array("DBCONFIG"));
     if (!empty(Server::$Configuration->Database["cct"][$this->TypeId])) {
         $loc = Server::$Configuration->Database["cct"][$this->TypeId]->GetLocalization($this->Language);
         if ($loc != null && !empty($loc->EmailVoucherUpdate)) {
             $email = $loc->EmailVoucherUpdate;
             $email = str_replace("%buyer_first_name%", $this->Firstname, $email);
             $email = str_replace("%buyer_last_name%", $this->Lastname, $email);
             $email = str_replace("%voucher_code%", $this->Id, $email);
             $email = str_replace("%voucher_remaining_time%", $this->ChatTimeRemaining == -1 ? "-" : ($this->ChatTimeRemaining >= 0 ? SystemTime::FormatTimeSpan($this->ChatTimeRemaining) : SystemTime::FormatTimeSpan(0)), $email);
             $email = str_replace("%voucher_remaining_sessions%", $this->ChatSessionsMax == -1 ? "-" : ($this->ChatSessionsMax - $this->ChatSessions >= 0 ? $this->ChatSessionsMax - $this->ChatSessions : 0), $email);
             $email = str_replace("%voucher_expiration_date%", $this->VoucherAutoExpire == -1 ? "-" : date("r", $this->VoucherAutoExpire), $email);
             $email = str_replace("%website_name%", Server::$Configuration->File["gl_site_name"], $email);
             $defmailbox = Mailbox::GetDefaultOutgoing();
             if ($defmailbox != null) {
                 Communication::SendEmail($defmailbox, $this->Email, $defmailbox->Email, $email, "", LocalizationManager::$TranslationStrings["client_voucher_email_subject_status_update"]);
             }
         }
     }
 }
 function SendStatusEmail()
 {
     global $CONFIG, $LZLANG;
     if (!empty($CONFIG["db"]["cct"][$this->TypeId])) {
         $loc = $CONFIG["db"]["cct"][$this->TypeId]->GetLocalization($this->Language);
         if ($loc != null && !empty($loc->EmailVoucherUpdate)) {
             $email = $loc->EmailVoucherUpdate;
             $email = str_replace("%buyer_first_name%", $this->Firstname, $email);
             $email = str_replace("%buyer_last_name%", $this->Lastname, $email);
             $email = str_replace("%voucher_code%", $this->Id, $email);
             $email = str_replace("%voucher_remaining_time%", $this->ChatTimeRemaining == -1 ? "-" : ($this->ChatTimeRemaining >= 0 ? formatTimeSpan($this->ChatTimeRemaining) : formatTimeSpan(0)), $email);
             $email = str_replace("%voucher_remaining_sessions%", $this->ChatSessionsMax == -1 ? "-" : ($this->ChatSessionsMax - $this->ChatSessions >= 0 ? $this->ChatSessionsMax - $this->ChatSessions : 0), $email);
             $email = str_replace("%voucher_expiration_date%", $this->VoucherAutoExpire == -1 ? "-" : date("r", $this->VoucherAutoExpire), $email);
             $email = str_replace("%website_name%", $CONFIG["gl_site_name"], $email);
             $defmailbox = Mailbox::GetDefaultOutgoing();
             if ($defmailbox != null) {
                 sendMail($defmailbox, $this->Email, $defmailbox->Email, $email, $LZLANG["client_voucher_email_subject_status_update"]);
             }
         }
     }
 }
 public function actionNewgroup()
 {
     $this->module->registerConfig($this->getAction()->getId());
     $cs = $this->module->getClientScript();
     $cs->registerScriptFile($this->module->getAssetsUrl() . '/js/compose.js');
     $cs->registerScriptFile($this->module->getAssetsUrl() . '/js/jquery.combobox.contacts.js');
     $js = '$(".mailbox-compose").yiiMailboxCompose(' . $this->module->getOptions() . ");";
     $cs->registerScript('mailbox-js', $js, CClientScript::POS_READY);
     if (!$this->module->authManager && (!$this->module->sendMsgs || $this->module->readOnly && !$this->module->isAdmin())) {
         $this->redirect(array('message/inbox'));
     }
     if (isset($_POST['Mailbox']['to']) and $_POST['Mailbox']['to'] != NULL) {
         $users = AuthAssignment::model()->findAllByAttributes(array('itemname' => $_POST['Mailbox']['to']));
         if ($users != NULL) {
             foreach ($users as $user) {
                 $t = time();
                 $conv = new Mailbox();
                 $conv->subject = $_POST['Mailbox']['subject'] ? $_POST['Mailbox']['subject'] : $this->module->defaultSubject;
                 $conv->to = $user->userid;
                 $conv->initiator_id = $this->module->getUserId();
                 $conv->interlocutor_id = $user->userid;
                 if ($conv->interlocutor_id && $conv->initiator_id == $conv->interlocutor_id) {
                     $conv->addError('to', "Can't send message to self!");
                 }
                 if (!$this->module->isAdmin() && $conv->interlocutor_id == $this->module->newsUserId) {
                     $conv->addError('to', "User not found?");
                 }
                 // check user-to-user perms
                 if (!$conv->hasErrors() && !$this->module->userToUser && !$this->module->isAdmin()) {
                     if (!$this->module->isAdmin($conv->to)) {
                         $conv->addError('to', "Invalid user!");
                     }
                 }
                 $conv->modified = $t;
                 $conv->bm_read = Mailbox::INITIATOR_FLAG;
                 if ($this->module->isAdmin()) {
                     $msg = new Message('admin');
                 } else {
                     $msg = new Message('user');
                 }
                 $msg->text = $_POST['Message']['text'];
                 $validate = $conv->validate(array('text'), false);
                 // html purify
                 $msg->created = $t;
                 $msg->sender_id = $conv->initiator_id;
                 $msg->recipient_id = $conv->interlocutor_id;
                 if ($this->module->checksums) {
                     $msg->crc64 = Message::crc64($msg->text);
                     // 64bit INT
                 } else {
                     $msg->crc64 = 0;
                 }
                 // Validate
                 $validate = $conv->validate(null, false);
                 // don't clear errors
                 $validate = $msg->validate() && $validate;
                 if ($validate) {
                     $conv->save();
                     $msg->conversation_id = $conv->conversation_id;
                     $msg->save();
                 }
                 Yii::app()->user->setFlash('success', "Message has been sent!");
             }
             $this->redirect(array('message/inbox'));
         } else {
             Yii::app()->user->setFlash('error', "Error sending message!");
             Yii::app()->user->setFlash('success', "Check Sent Mail");
         }
     } else {
         $conv = new Mailbox();
         if (isset($_GET['id'])) {
             $conv->to = $this->module->getUserName($_GET['id']);
         } elseif (isset($_GET['to'])) {
             $conv->to = $_GET['to'];
         } else {
             $conv->to = '';
         }
         $msg = new Message();
     }
     $this->render('composetogroup', array('conv' => $conv, 'msg' => $msg));
 }
示例#26
0
 private function _sendSettingsEmail($cc = false, $password = '', $isWelcome = false)
 {
     $mailer = new Zend_Mail();
     if ($isWelcome) {
         $mailer->setSubject(_("Welcome to your new mailbox on") . " {$this->_mailbox['domain']}");
     } else {
         $mailer->setSubject(_("Settings for your mailbox on") . " {$this->_mailbox['domain']}");
     }
     $mailer->setFrom($this->_options['server']['email']['address'], $this->_options['server']['email']['name']);
     $mailer->addTo($this->_mailbox['username'], $this->_mailbox['name']);
     if ($cc) {
         $mailer->addCc($cc);
     }
     $this->view->mailbox = $this->_mailbox;
     $this->view->welcome = $isWelcome;
     $this->view->password = $password;
     $settings = $this->_options['server'];
     foreach ($settings as $tech => $params) {
         foreach ($params as $k => $v) {
             $settings[$tech][$k] = Mailbox::substitute($this->_mailbox['username'], $v);
         }
     }
     $this->view->settings = $settings;
     $mailer->setBodyText($this->view->render('mailbox/email/settings.phtml'));
     try {
         $mailer->send();
         return true;
     } catch (Exception $e) {
     }
     return false;
 }
 public function cron()
 {
     $deleted_convs = Mailbox::model()->deleted()->findAll();
     foreach ($deleted_convs as $conv) {
         $conv->recycle();
     }
 }
示例#28
0
             $msg->delete();
         }
     }
     exit();
 } elseif (isset($_POST['all_outbox'])) {
     $outbox = new Mailbox($uid, $course_id);
     $msgs = $outbox->getOutboxMsgs();
     foreach ($msgs as $msg) {
         if (!$msg->error) {
             $msg->delete();
         }
     }
     exit();
 }
 
 $mbox = new Mailbox($uid, $course_id);
 
 $limit = intval($_GET['iDisplayLength']);
 $offset = intval($_GET['iDisplayStart']);
 
 //Total records
 $data['iTotalRecords'] = $mbox->MsgsNumber($mbox_type);
 
 $keyword = $_GET['sSearch'];
 
 if ($mbox_type == 'inbox') {
     //Total records after applying search filter
     $data['iTotalDisplayRecords'] = count($mbox->getInboxMsgs($keyword));
     
     $msgs = $mbox->getInboxMsgs($keyword, $limit, $offset);
 } else {
function processTicketActions($count = 0)
{
    global $GROUPS, $CONFIG;
    $temporaryIds = array();
    while (isset($_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vc"])) {
        $type = $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vc"];
        if ($type == "SetTicketStatus") {
            $Ticket = new Ticket();
            $Ticket->Id = $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_va"];
            if ($_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_0"] != $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_2"]) {
                $Ticket->Log(0, CALLER_SYSTEM_ID, $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_0"], $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_2"]);
            }
            if (!empty($_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vb"]) && $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vb"] != $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_3"]) {
                $Ticket->Log(2, CALLER_SYSTEM_ID, $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vb"], $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_3"]);
            }
            if ($_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_1"] != $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_4"]) {
                $Ticket->Log(3, CALLER_SYSTEM_ID, $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_1"], $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_4"]);
            }
            $TicketEditor = new TicketEditor($_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_va"]);
            if (!empty($_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vb"])) {
                $TicketEditor->Editor = $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vb"];
            }
            $TicketEditor->Status = $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_0"];
            $TicketEditor->GroupId = $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_1"];
            $TicketEditor->Save();
            if ($_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_1"] != $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_4"]) {
                $Ticket->SetGroup($_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_1"]);
            }
            $Ticket->Editor = $TicketEditor;
            $Ticket->LoadMessages();
            $Ticket->SetLastUpdate(time());
        } else {
            if ($type == "AddTicketEditorReply") {
                $Ticket = new Ticket($_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_va"], $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_3"]);
                $Ticket->Group = $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_4"];
                $Ticket->Messages[0]->Id = $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_6"];
                $Ticket->Messages[0]->ChannelId = getId(32);
                $Ticket->Messages[0]->Hash = $Ticket->GetHash(false);
                $Ticket->Messages[0]->SenderUserId = $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vb"];
                $Ticket->Messages[0]->Type = 1;
                $Ticket->Messages[0]->Email = $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_2"];
                $Ticket->Messages[0]->Text = Mailbox::FinalizeEmail($_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_0"]);
                $Ticket->Messages[0]->Subject = $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_5"];
                $Ticket->Messages[0]->Save($_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_va"], time());
                $acount = 7;
                $att = array();
                while (isset($_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_" . $acount])) {
                    $att[$_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_" . $acount]] = $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_" . $acount];
                    $Ticket->Messages[0]->ApplyAttachment($_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_" . $acount++]);
                }
                $mailbox = Mailbox::GetById($GROUPS[$Ticket->Group]->TicketEmailOut, true);
                $Ticket->SendEditorReply($mailbox, $Ticket->Messages[0]->Text, getPredefinedMessage($GROUPS[$Ticket->Group]->PredefinedMessages, $Ticket->Language), $att, $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_5"]);
                if (!empty($CONFIG["gl_ctor"])) {
                    $Ticket->LoadStatus();
                    $Ticket->Editor->Status = TICKET_STATUS_CLOSED;
                    $Ticket->Editor->Save();
                }
                $Ticket->SetLastUpdate(time());
            } else {
                if ($type == "SetTicketLanguage") {
                    $Ticket = new Ticket($_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_0"], $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_1"]);
                    $Ticket->SetLanguage($_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_1"]);
                    $Ticket->Log(1, CALLER_SYSTEM_ID, $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_1"], $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_2"]);
                    $Ticket->SetLastUpdate(time());
                } else {
                    if ($type == "DeleteTicketFromServer") {
                        $Ticket = new Ticket($_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_0"], "");
                        $Ticket->Destroy();
                        $Ticket->Log(7, CALLER_SYSTEM_ID, 0, 1);
                        $Ticket->SetLastUpdate(time());
                    } else {
                        if ($type == "AddComment") {
                            $Ticket = new TicketMessage($_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_1"], "");
                            $Ticket->AddComment(CALLER_SYSTEM_ID, $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_0"], $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_2"]);
                            $Ticket = new Ticket($_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_2"], "");
                            $Ticket->SetLastUpdate(time());
                        } else {
                            if ($type == "LinkChat") {
                                if (!empty($temporaryIds[$_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_0"]])) {
                                    $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_0"] = $temporaryIds[$_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_0"]];
                                }
                                $Ticket = new Ticket($_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_0"], "");
                                $Ticket->LinkChat($_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_1"], getId(32));
                                $Ticket->Log(5, CALLER_SYSTEM_ID, $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_0"], $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_1"]);
                                $Ticket->SetLastUpdate(time());
                            } else {
                                if ($type == "LinkTicket") {
                                    $Ticket = new Ticket($_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_0"], "");
                                    $TicketSub = new Ticket($_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_1"], "");
                                    $counts[$Ticket->Id] = Ticket::GetMessageCount($Ticket->Id);
                                    $counts[$TicketSub->Id] = Ticket::GetMessageCount($TicketSub->Id);
                                    if ($counts[$Ticket->Id] > $counts[$TicketSub->Id]) {
                                        $Ticket->LinkTicket($TicketSub->Id, getId(32));
                                    } else {
                                        $TicketSub->LinkTicket($Ticket->Id, getId(32));
                                    }
                                    $Ticket->SetLastUpdate(time());
                                } else {
                                    if ($type == "EditMessage") {
                                        $ticket = new Ticket($_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_1"], "");
                                        $message = new TicketMessage($_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_0"], "");
                                        $message->Load();
                                        $message->ChangeValue($ticket, 10, CALLER_SYSTEM_ID, $message->Fullname, $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_2"]);
                                        $message->ChangeValue($ticket, 11, CALLER_SYSTEM_ID, $message->Email, $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_3"]);
                                        $message->ChangeValue($ticket, 12, CALLER_SYSTEM_ID, $message->Company, $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_4"]);
                                        $message->ChangeValue($ticket, 13, CALLER_SYSTEM_ID, $message->Phone, $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_5"]);
                                        $message->ChangeValue($ticket, 14, CALLER_SYSTEM_ID, $message->Subject, $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_6"]);
                                        $message->ChangeValue($ticket, 15, CALLER_SYSTEM_ID, $message->Text, $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_7"]);
                                        $message->ApplyCustomFromPost($count, true, $ticket, CALLER_SYSTEM_ID);
                                        $message->Save($_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_1"], true);
                                        $ticket->SetLastUpdate(time(), false);
                                    } else {
                                        if ($type == "CreateTicket") {
                                            $Ticket = new Ticket(getObjectId("ticket_id", DATABASE_TICKETS), "");
                                            $temporaryIds[$_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_11"]] = $Ticket->Id;
                                            $Ticket->Messages[0]->Id = $Ticket->Id;
                                            $Ticket->Messages[0]->ChannelId = $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_4"];
                                            $Ticket->CreationType = $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_3"];
                                            $Ticket->Group = $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_6"];
                                            $Ticket->Language = strtoupper(trim($_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_10"]));
                                            $Ticket->Messages[0]->Fullname = $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_0"];
                                            $Ticket->Messages[0]->Email = $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_1"];
                                            $Ticket->Messages[0]->Text = $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_2"];
                                            $Ticket->Messages[0]->Company = $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_7"];
                                            $Ticket->Messages[0]->Phone = $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_8"];
                                            $Ticket->Messages[0]->Type = $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_9"];
                                            $Ticket->Messages[0]->Subject = $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_15"];
                                            $Ticket->Messages[0]->ApplyCustomFromPost($count);
                                            $cid = 0;
                                            while (isset($_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_" . $cid])) {
                                                $value = $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_" . $cid++];
                                                if (strpos($value, "[att]") === 0) {
                                                    $Ticket->Messages[0]->ApplyAttachment(base64_decode(str_replace("[att]", "", $value)));
                                                } else {
                                                    if (strpos($value, "[com]") === 0) {
                                                        $Ticket->Messages[0]->AddComment(CALLER_SYSTEM_ID, $Ticket->Id, base64_decode(str_replace("[com]", "", $value)));
                                                    }
                                                }
                                            }
                                            $Ticket->Messages[0]->LoadAttachments();
                                            if (!empty($_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_4"])) {
                                                $email = new TicketEmail($_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_4"], false, "");
                                                $email->LoadAttachments();
                                                foreach ($email->Attachments as $rid => $res) {
                                                    if (empty($Ticket->Messages[0]->Attachments[$rid])) {
                                                        processResource(CALLER_SYSTEM_ID, $rid, "", RESOURCE_TYPE_FILE_INTERNAL, "", true, 100, 1, 0);
                                                    }
                                                }
                                                $email->Destroy();
                                            }
                                            $Ticket->Save();
                                            $TicketEditor = new TicketEditor($Ticket->Id);
                                            $TicketEditor->Editor = $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_13"];
                                            $TicketEditor->Status = $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_12"];
                                            $TicketEditor->GroupId = $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_14"];
                                            $TicketEditor->Save();
                                            $Ticket->Log(6, CALLER_SYSTEM_ID, $Ticket->Id, "");
                                            $Ticket->SetLastUpdate(time());
                                        } else {
                                            if ($type == "SetEmailStatus") {
                                                $Email = new TicketEmail($_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_0"], $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_1"], $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_2"]);
                                                $Email->SetStatus();
                                            } else {
                                                if ($type == "ForwardMessage") {
                                                    $message = new TicketMessage($_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_0"], "");
                                                    $message->Load();
                                                    $message->Forward($_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_1"], $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_2"], $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_3"], $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_4"]);
                                                    $ticket = new Ticket($_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_5"], "");
                                                    $ticket->Log(9, CALLER_SYSTEM_ID, $message->Id, $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_2"]);
                                                } else {
                                                    if ($type == "MoveMessageIntoTicket") {
                                                        $message = new TicketMessage($_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_1"], "");
                                                        $message->Load(true);
                                                        $message->ChannelId = getId(32);
                                                        $ticket = new Ticket($_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_0"], "");
                                                        $ticket->Load();
                                                        $ticket->Id = $message->Id = getObjectId("ticket_id", DATABASE_TICKETS);
                                                        $ticket->Messages = array();
                                                        $ticket->Messages[0] = $message;
                                                        $ticket->Save();
                                                        $ticket->Log(8, CALLER_SYSTEM_ID, $ticket->Id, $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_0"]);
                                                        $message->SaveAttachments();
                                                        $message->SaveComments($ticket->Id);
                                                    } else {
                                                        if ($type == "DeleteAttachment") {
                                                            processResource(CALLER_SYSTEM_ID, $_POST[POST_INTERN_PROCESS_TICKET_ACTIONS . "_" . $count . "_vd_0"], "", RESOURCE_TYPE_FILE_INTERNAL, "", true, "100", "1");
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        $count++;
    }
    if ($count > 0) {
        CacheManager::SetDataUpdateTime(DATA_UPDATE_KEY_TICKETS);
        CacheManager::SetDataUpdateTime(DATA_UPDATE_KEY_EMAILS);
    }
}
示例#30
0
/**
 * Function lessonToolsMenu
 *
 * Creates a multi-dimensional array of the user's tools
 * in regard to the user's user level
 * (student | professor | platform administrator)
 *
 * @return array
 */
function lessonToolsMenu() {
    global $uid, $is_editor, $is_course_admin, $courses,
           $course_code, $langAdministrationTools, $langExternalLinks,
           $modules, $admin_modules, $urlAppend, $status, $course_id;

    $sideMenuGroup = array();
    $sideMenuSubGroup = array();
    $sideMenuText = array();
    $sideMenuLink = array();
    $sideMenuImg = array();
    $sideMenuID = array();

    $arrMenuType = array();
    $arrMenuType['type'] = 'none';

    if ($is_editor || $is_course_admin) {
        $tools_sections =
            array(array('type' => 'Public',
                        'title' => $GLOBALS['langActiveTools'],
                        'iconext' => '_on.png',
                        'class' => 'active'),
                  array('type' => 'PublicButHide',
                        'title' => $GLOBALS['langInactiveTools'],
                        'iconext' => '_off.png',
                        'class' => 'inactive'));
    } else {
        $tools_sections =
            array(array('type' => 'Public',
                        'title' => $GLOBALS['langCourseOptions'],
                        'iconext' => '_on.png',
                        'class' => 'active'));
    }

    foreach ($tools_sections as $section) {
        $result = getToolsArray($section['type']);

        $sideMenuSubGroup = array();
        $sideMenuText = array();
        $sideMenuLink = array();
        $sideMenuImg = array();
        $sideMenuID = array();
        $mail_status = '';
        $arrMenuType = array('type' => 'text',
                             'text' => $section['title'],
                             'class' => $section['class']);
        array_push($sideMenuSubGroup, $arrMenuType);

        setlocale(LC_COLLATE, $GLOBALS['langLocale']);
        usort($result, function ($a, $b) {
            global $modules;
            return strcoll($modules[$a->module_id]['title'], $modules[$b->module_id]['title']);
        });

        // check if we have define mail address and want to receive messages
        if ($uid and $status != USER_GUEST and !get_user_email_notification($uid, $course_id)) {
            $mail_status = '&nbsp;' . icon('fa-exclamation-triangle');
        }

        foreach ($result as $toolsRow) {
            $mid = $toolsRow->module_id;

            // hide groups for unregistered users
            if ($mid == MODULE_ID_GROUPS and !$courses[$course_code]) {
                continue;
            }

            // hide teleconference when no BBB servers are enabled
            if ($mid == MODULE_ID_BBB and !get_total_bbb_servers()) {
                continue;
            }

            // if we are in dropbox or announcements add (if needed) mail address status
            if ($mid == MODULE_ID_DROPBOX or $mid == MODULE_ID_ANNOUNCE) {
                if ($mid == MODULE_ID_DROPBOX) {
                    $mbox = new Mailbox($uid, course_code_to_id($course_code));
                    $new_msgs = $mbox->unreadMsgsNumber();
                    if ($new_msgs != 0) {
                        array_push($sideMenuText, '<b>' . q($modules[$mid]['title']) .
                            " $mail_status<span class='badge pull-right'>$new_msgs</span></b>");
                    } else {
                        array_push($sideMenuText, q($modules[$mid]['title']).' '.$mail_status);
                    }
                } else {
                    array_push($sideMenuText, q($modules[$mid]['title']).' '.$mail_status);
                }
            } elseif ($mid == MODULE_ID_DOCS and ($new_docs = get_new_document_count($course_id))) {
                array_push($sideMenuText, '<b>' . q($modules[$mid]['title']) .
                    "<span class='badge pull-right'>$new_docs</span></b>");
            } else {
                array_push($sideMenuText, q($modules[$mid]['title']));
            }

            array_push($sideMenuLink, q($urlAppend . 'modules/' . $modules[$mid]['link'] .
                            '/?course=' . $course_code));
            array_push($sideMenuImg, $modules[$mid]['image'] . $section['iconext']);
            array_push($sideMenuID, $mid);
        }
        array_push($sideMenuSubGroup, $sideMenuText);
        array_push($sideMenuSubGroup, $sideMenuLink);
        array_push($sideMenuSubGroup, $sideMenuImg);
        array_push($sideMenuSubGroup, $sideMenuID);
        array_push($sideMenuGroup, $sideMenuSubGroup);
    }
    $result2 = getExternalLinks();
    if ($result2) { // display external link (if any)
        $sideMenuSubGroup = array();
        $sideMenuText = array();
        $sideMenuLink = array();
        $sideMenuImg = array();
        $arrMenuType = array('type' => 'text',
                             'text' => $langExternalLinks,
                             'class' => 'external');
        array_push($sideMenuSubGroup, $arrMenuType);

        foreach ($result2 as $ex_link) {
            array_push($sideMenuText, q($ex_link->title));
            array_push($sideMenuLink, q($ex_link->url));
            array_push($sideMenuImg, 'fa-external-link');
        }

        array_push($sideMenuSubGroup, $sideMenuText);
        array_push($sideMenuSubGroup, $sideMenuLink);
        array_push($sideMenuSubGroup, $sideMenuImg);
        array_push($sideMenuGroup, $sideMenuSubGroup);
    }
    if ($is_course_admin) {  // display course admin tools
        $sideMenuSubGroup = array();
        $sideMenuText = array();
        $sideMenuLink = array();
        $sideMenuImg = array();
        $sideMenuID = array();
        $arrMenuType = array('type' => 'text',
                             'text' => $langAdministrationTools,
                             'class' => 'course_admin');
        array_push($sideMenuSubGroup, $arrMenuType);

        foreach ($admin_modules as $adm_mod) {
            array_push($sideMenuText, $adm_mod['title']);
            array_push($sideMenuLink, q($urlAppend . 'modules/' . $adm_mod['link'] .
                            '/?course=' . $course_code));
            array_push($sideMenuImg, $adm_mod['image'] . $section['iconext']);
        }

        array_push($sideMenuSubGroup, $sideMenuText);
        array_push($sideMenuSubGroup, $sideMenuLink);
        array_push($sideMenuSubGroup, $sideMenuImg);
        array_push($sideMenuSubGroup, $sideMenuID);
        array_push($sideMenuGroup, $sideMenuSubGroup);
    }
    return $sideMenuGroup;
}