コード例 #1
0
/**
* Получить информацию о контакте.
*
* @param    integer $id     идентификатор контакта
*/
function GetContactInfo($id)
{
    session_start();
    $objResponse = new xajaxResponse();
    if (hasPermissions('ourcontacts')) {
        $c = contacts::getContactInfo($id);
        $objResponse->assign('fld_edit_id', 'value', $c['id']);
        $objResponse->assign('fld_edit_name', 'value', $c['name']);
        $objResponse->assign('fld_edit_surname', 'value', $c['surname']);
        $objResponse->assign('fld_edit_company', 'value', $c['company']);
        $objResponse->assign('fld_edit_note', 'value', $c['note']);
        $objResponse->script("xajax_GetGroupsForSelect({$c['group_id']}, 'fld_edit_group');");
        if ($c['emails']) {
            $objResponse->assign('fld_edit_email', 'value', $c['emails'][0]);
            for ($i = 1; $i < count($c['emails']); ++$i) {
                $objResponse->script("ContactsAddField('edit_contact_li_email','email','edit');");
                $objResponse->assign('fld_edit_email_' . $i, 'value', $c['emails'][$i]);
            }
        }
        if ($c['phones']) {
            $objResponse->assign('fld_edit_phone', 'value', $c['phones'][0]);
            for ($i = 1; $i < count($c['phones']); ++$i) {
                $objResponse->script("ContactsAddField('edit_contact_li_phone','phone','edit');");
                $objResponse->assign('fld_edit_phone_' . $i, 'value', $c['phones'][$i]);
            }
        }
        if ($c['skypes']) {
            $objResponse->assign('fld_edit_skype', 'value', $c['skypes'][0]);
            for ($i = 1; $i < count($c['skypes']); ++$i) {
                $objResponse->script("ContactsAddField('edit_contact_li_skype','skype','edit');");
                $objResponse->assign('fld_edit_skype_' . $i, 'value', $c['skypes'][$i]);
            }
        }
        if ($c['icqs']) {
            $objResponse->assign('fld_edit_icq', 'value', $c['icqs'][0]);
            for ($i = 1; $i < count($c['icqs']); ++$i) {
                $objResponse->script("ContactsAddField('edit_contact_li_icq','icq','edit');");
                $objResponse->assign('fld_edit_icq_' . $i, 'value', $c['icqs'][$i]);
            }
        }
        if ($c['others']) {
            $objResponse->assign('fld_edit_other', 'value', $c['others'][0]);
            for ($i = 1; $i < count($c['others']); ++$i) {
                $objResponse->script("ContactsAddField('edit_contact_li_other','other','edit');");
                $objResponse->assign('fld_edit_other_' . $i, 'value', $c['others'][$i]);
            }
        }
    }
    return $objResponse;
}
コード例 #2
0
ファイル: smail.php プロジェクト: kapai69/fl-ru-damp
 /**
  * Отправляет email контакам из /siteadmin/contacts/. Вызвается из hourly.php.
  *
  * @return string возможная ошибка
  */
 public function SendMailToContacts()
 {
     require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/contacts.php';
     require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/users.php';
     $mails = contacts::GetMails();
     if ($mails) {
         $fromSave = $this->from;
         foreach ($mails as $mail) {
             $user = new users();
             $user->GetUser($user->GetField($mail['user_id'], $ee, 'login'));
             $this->subject = $mail['subject'];
             $attaches = array();
             if ($mail['attaches']) {
                 $files = preg_split('/,/', $mail['attaches']);
                 foreach ($files as $a) {
                     $attaches[] = new CFile('users/' . substr($user->login, 0, 2) . '/' . $user->login . '/upload/' . $a);
                 }
                 $attaches = $this->CreateAttach($attaches);
             }
             $contact_ids = preg_split('/,/', $mail['contact_ids']);
             foreach ($contact_ids as $contact_id) {
                 $contact = contacts::getContactInfo($contact_id);
                 if ($contact['emails']) {
                     $msg_text = $mail['message'];
                     $msg_text = preg_replace('/%CONTACT_NAME%/', $contact['name'], $msg_text);
                     $msg_text = preg_replace('/%CONTACT_SURNAME%/', $contact['surname'], $msg_text);
                     $msg_text = preg_replace('/%CONTACT_COMPANY%/', $contact['company'], $msg_text);
                     foreach ($contact['emails'] as $email) {
                         $this->from = '*****@*****.**';
                         $this->recipient = $contact['name'] . ' <' . $email . '>';
                         $this->message = $msg_text;
                         $this->SmtpMail('text/html', $attaches);
                     }
                 }
             }
             contacts::DeleteMail($mail['id']);
         }
         $this->from = $fromSave;
     }
     return '';
 }