当前位置: 首页>>代码示例>>PHP>>正文


PHP Emails::save方法代码示例

本文整理汇总了PHP中Emails::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Emails::save方法的具体用法?PHP Emails::save怎么用?PHP Emails::save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Emails的用法示例。


在下文中一共展示了Emails::save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: pushMail

 public function pushMail($subject, $message, $address, $priority)
 {
     if (isset($address['email']) && isset($address['name'])) {
         $email = new Emails();
         $email->email_subject = $subject;
         $email->email_body = $message;
         $email->email_priority = $priority;
         $email->email_toName = $address['name'];
         $email->email_toMail = $address['email'];
         $email->save(false);
     } else {
         for ($i = 0; $i < count($address); $i++) {
             $email = new Emails();
             $email->email_subject = $subject;
             $email->email_body = $message;
             $email->email_priority = $priority;
             if (is_array($address[$i])) {
                 $email->email_toName = $address[$i]['name'];
                 $email->email_toMail = $address[$i]['email'];
                 $email->save(false);
             } else {
                 $email->email_toName = str_replace('"', '', $address[$i]);
                 $email->email_toMail = str_replace('"', '', $address[$i]);
                 $email->save(false);
             }
         }
     }
 }
开发者ID:lanzelotik,项目名称:celestic-community,代码行数:28,代码来源:yiiPhpMailer.php

示例2: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Emails();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Emails'])) {
         $model->attributes = $_POST['Emails'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model));
 }
开发者ID:ronwar76,项目名称:PassPort,代码行数:17,代码来源:EmailsController.php

示例3: actionAddEmail

 public function actionAddEmail()
 {
     if(isset($_POST['url'])) {
         $email = Emails::model()->find(array('condition'=>'email = :email', 'params'=>array(':email'=>$_POST['url'])));
         if($email) {
             echo Yii::t('main', 'Такий email уже використовується');
         }else{
             $email = new Emails();
             $email->email = $_POST['url'];
             if($email->save())
                 echo Yii::t('main', 'Дякуэмо за підписку!');
         }
     }
 }
开发者ID:Vladimirtishenko,项目名称:garmata.tv,代码行数:14,代码来源:AjaxController.php

示例4: track_email

function track_email($user_name, $password, $contact_ids, $date_sent, $email_subject, $email_body)
{
    if (authentication($user_name, $password)) {
        global $current_user;
        global $adb;
        global $log;
        require_once 'modules/Users/Users.php';
        require_once 'modules/Emails/Emails.php';
        $current_user = new Users();
        $user_id = $current_user->retrieve_user_id($user_name);
        $query = "select email1 from vtiger_users where id =?";
        $result = $adb->pquery($query, array($user_id));
        $user_emailid = $adb->query_result($result, 0, "email1");
        $current_user = $current_user->retrieveCurrentUserInfoFromFile($user_id);
        $email = new Emails();
        //$log->debug($msgdtls['contactid']);
        $emailbody = str_replace("'", "''", $email_body);
        $emailsubject = str_replace("'", "''", $email_subject);
        $datesent = substr($date_sent, 1, 10);
        $mydate = date('Y-m-d', $datesent);
        $mydate = DateTimeField::convertToDBFormat($mydate);
        $email->column_fields[subject] = $emailsubject;
        $email->column_fields[assigned_user_id] = $user_id;
        $email->column_fields[date_start] = $mydate;
        $email->column_fields[description] = $emailbody;
        $email->column_fields[activitytype] = 'Emails';
        $email->plugin_save = true;
        $email->save("Emails");
        $query = "select fieldid from vtiger_field where fieldname = 'email' and tabid = 4 and vtiger_field.presence in (0,2)";
        $result = $adb->pquery($query, array());
        $field_id = $adb->query_result($result, 0, "fieldid");
        $email->set_emails_contact_invitee_relationship($email->id, $contact_ids);
        $email->set_emails_se_invitee_relationship($email->id, $contact_ids);
        $email->set_emails_user_invitee_relationship($email->id, $user_id);
        $sql = "select email from vtiger_contactdetails inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_contactdetails.contactid where vtiger_crmentity.deleted =0 and vtiger_contactdetails.contactid=?";
        $result = $adb->pquery($sql, array($contact_ids));
        $camodulerow = $adb->fetch_array($result);
        if (isset($camodulerow)) {
            $emailid = $camodulerow["email"];
            //added to save < as $lt; and > as &gt; in the database so as to retrive the emailID
            $user_emailid = str_replace('<', '&lt;', $user_emailid);
            $user_emailid = str_replace('>', '&gt;', $user_emailid);
            $query = 'insert into vtiger_emaildetails values (?,?,?,?,?,?,?,?)';
            $params = array($email->id, $emailid, $user_emailid, "", "", "", $user_id . '@-1|' . $contact_ids . '@' . $field_id . '|', "THUNDERBIRD");
            $adb->pquery($query, $params);
        }
        return $email->id;
    }
}
开发者ID:casati-dolibarr,项目名称:corebos,代码行数:49,代码来源:thunderbirdplugin.php

示例5: actionIndex

 public function actionIndex()
 {
     $recipients = $_POST['recipients'];
     $title = $_POST['title'];
     $message = $_POST['message'];
     $profile_url = 'http://' . $_SERVER['SERVER_NAME'] . '/user/profile/edit';
     $message_ps = '<br><br>' . ProjectModule::t('You can unsubscribe...') . ':';
     $message_ps .= '<br><a href="' . $profile_url . '">' . $profile_url . '</a>';
     if ($recipients && $message && $title) {
         if ($recipients == 'executors') {
             $role = 'Author';
         } elseif ($recipients == 'customers') {
             $role = 'Customer';
         }
         //$users = User::model()->findAllCustomers();
         $users = User::model()->resetScope()->Role($role)->with(array('profile' => array('select' => array('profile.general_mailing'))))->findAll();
         foreach ($users as $user) {
             if (!$user->profile || $user->profile->general_mailing == 1) {
                 $email = new Emails();
                 $email->to = $user->email;
                 $email->subject = $title;
                 $email->body = $message . $message_ps;
                 $email->type = 0;
                 $email->dt = time();
                 $email->save();
                 //print_r( $user );
                 //echo $email->body;
                 //echo '<br>';
             }
         }
         //print_r($users);
         $title = '';
         $message = '';
         $recipients = null;
         $result = ProjectModule::t('Your message is sending...');
     } else {
         $result = ProjectModule::t('Something wrong...');
     }
     $this->render('index', array('title' => $title, 'message' => $message, 'recipients' => $recipients, 'result' => $result));
 }
开发者ID:akoch-ov,项目名称:dipstart-development,代码行数:40,代码来源:EmailsController.php

示例6: Emails

 /**
  * Create new Email record (and link to given record) including attachments
  * @global Users $current_user
  * @global PearDataBase $adb
  * @param  MailManager_Message_Model $mailrecord
  * @param String $module
  * @param CRMEntity $linkfocus
  * @return Integer
  */
 function __CreateNewEmail($mailrecord, $module, $linkfocus)
 {
     global $current_user, $adb;
     if (!$current_user) {
         $current_user = Users::getActiveAdminUser();
     }
     $handler = vtws_getModuleHandlerFromName('Emails', $current_user);
     $meta = $handler->getMeta();
     if ($meta->hasWriteAccess() != true) {
         return false;
     }
     $focus = new Emails();
     $focus->column_fields['activitytype'] = 'Emails';
     $focus->column_fields['subject'] = $mailrecord->_subject;
     if (!empty($module)) {
         $focus->column_fields['parent_type'] = $module;
     }
     if (!empty($linkfocus->id)) {
         $focus->column_fields['parent_id'] = "{$linkfocus->id}@-1|";
     }
     $focus->column_fields['description'] = $mailrecord->getBodyHTML();
     $focus->column_fields['assigned_user_id'] = $current_user->id;
     $focus->column_fields["date_start"] = date('Y-m-d', $mailrecord->_date);
     $focus->column_fields["email_flag"] = 'MailManager';
     $from = $mailrecord->_from[0];
     $to = $mailrecord->_to[0];
     $cc = !empty($mailrecord->_cc) ? implode(',', $mailrecord->_cc) : '';
     $bcc = !empty($mailrecord->_bcc) ? implode(',', $mailrecord->_bcc) : '';
     //emails field were restructured and to,bcc and cc field are JSON arrays
     $focus->column_fields['from_email'] = $from;
     $focus->column_fields['saved_toid'] = $to;
     $focus->column_fields['ccmail'] = $cc;
     $focus->column_fields['bccmail'] = $bcc;
     $focus->save('Emails');
     $emailid = $focus->id;
     // TODO: Handle attachments of the mail (inline/file)
     $this->__SaveAttachements($mailrecord, 'Emails', $focus);
     return $emailid;
 }
开发者ID:nouphet,项目名称:vtigercrm-6.0.0-ja,代码行数:48,代码来源:Relate.php

示例7: actionSend

 public function actionSend()
 {
     $model = new Emails();
     $this->_prepairJson();
     $orderId = $this->_request->getParam('orderId');
     $typeId = $this->_request->getParam('typeId');
     $back = $this->_request->getParam('back');
     $cost = $this->_request->getParam('cost');
     $order = Zakaz::model()->findByPk($orderId);
     $arr_type = array(Emails::TYPE_18, Emails::TYPE_19, Emails::TYPE_20, Emails::TYPE_21, Emails::TYPE_22, Emails::TYPE_23, Emails::TYPE_24);
     if (in_array($typeId, $arr_type)) {
         $user = User::model()->findByPk($order->executor);
     } else {
         $user = User::model()->findByPk($order->user_id);
     }
     $model->to_id = $user->id;
     $profile = Profile::model()->findAll("`user_id`='{$user->id}'");
     $rec = Templates::model()->findAll("`type_id`='{$typeId}'");
     $title = $rec[0]->title;
     $model->name = $profle->firstname;
     if (strlen($model->name) < 2) {
         $model->name = $user->username;
     }
     $model->login = $user->username;
     $model->num_order = $orderId;
     $model->page_order = 'http://' . $_SERVER['SERVER_NAME'] . '/project/chat?orderId=' . $orderId;
     $model->message = $rec[0]->text;
     $model->price_order = $cost;
     $this->sum_order = $cost;
     $model->sendTo($user->email, $rec[0]->text, $typeId);
     $model->save();
     /*		
     		if (!isset($back)) $back = 'index';
             $this->render($back, [
                 'model'=>$model
             ]);
     */
 }
开发者ID:kibercoder,项目名称:dipstart-development,代码行数:38,代码来源:EmailsController.php

示例8: AddMessageToContact

function AddMessageToContact($username, $session, $contactid, $msgdtls)
{
    if (!validateSession($username, $session)) {
        return null;
    }
    global $current_user;
    global $adb;
    require_once 'modules/Users/Users.php';
    require_once 'modules/Emails/Emails.php';
    $current_user = new Users();
    $user_id = $current_user->retrieve_user_id($username);
    $query = "select email1 from vtiger_users where id = ?";
    $result = $adb->pquery($query, array($user_id));
    $user_emailid = $adb->query_result($result, 0, "email1");
    $current_user = $current_user->retrieveCurrentUserInfoFromFile($user_id);
    foreach ($msgdtls as $msgdtl) {
        if (isset($msgdtl)) {
            $email = new Emails();
            //$log->debug($msgdtls['contactid']);
            $email_body = str_replace("'", "''", $msgdtl['body']);
            $email_body = str_replace('<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">', " ", $email_body);
            $email_subject = str_replace("'", "''", $msgdtl['subject']);
            $date_sent = getDisplayDate($msgdtl['datesent']);
            $email->column_fields[subject] = $email_subject;
            $email->column_fields[assigned_user_id] = $user_id;
            $email->column_fields[date_start] = $date_sent;
            $email->column_fields[description] = $email_body;
            $email->column_fields[activitytype] = 'Emails';
            $email->column_fields[email_flag] = 'SENT';
            $email->plugin_save = true;
            $email->save("Emails");
            $query = "select fieldid from vtiger_field where fieldname = 'email' and tabid = 4 and vtiger_field.presence in (0,2)";
            $result = $adb->pquery($query, array());
            $field_id = $adb->query_result($result, 0, "fieldid");
            $email->set_emails_contact_invitee_relationship($email->id, $contactid);
            $email->set_emails_se_invitee_relationship($email->id, $contactid);
            $email->set_emails_user_invitee_relationship($email->id, $user_id);
            return $email->id;
        } else {
            return "";
        }
    }
}
开发者ID:hardikk,项目名称:HNH,代码行数:43,代码来源:vtigerolservice.php

示例9: handleTask


//.........这里部分代码省略.........
             $mailtemplate = $adb->fetchByAssoc($result);
             $content = str_replace('$mailtext', $content, html_entity_decode($mailtemplate["body"], ENT_COMPAT, 'UTF-8'));
             $content = Vtiger_Functions::getMergedDescription($content, $context->getId(), $context->getModuleName());
         } else {
             $parts = explode('#', $mailtemplate);
             switch ($parts[1]) {
                 case 'emailmaker':
                     $templateid = $parts[2];
                     $sql = 'SELECT body, subject FROM vtiger_emakertemplates WHERE templateid = ?';
                     $result = $adb->pquery($sql, array($templateid));
                     $EMAILContentModel = \EMAILMaker_EMAILContent_Model::getInstance($this->getModuleName(), $context->getId(), $current_language, $context->getId(), $this->getModuleName());
                     $EMAILContentModel->setSubject($adb->query_result($result, 0, 'subject'));
                     $EMAILContentModel->setBody($adb->query_result($result, 0, 'body'));
                     $EMAILContentModel->getContent(true);
                     $embeddedImages = $EMAILContentModel->getEmailImages();
                     $subject = $EMAILContentModel->getSubject();
                     $content = $EMAILContentModel->getBody();
                     break;
             }
         }
     }
     #$content = htmlentities($content, ENT_NOQUOTES, "UTF-8");
     if (getTabid('Emails') && vtlib_isModuleActive('Emails')) {
         require_once 'modules/Emails/Emails.php';
         $focus = new Emails();
         $focus->column_fields["assigned_user_id"] = \Workflow\VTEntity::getUser()->id;
         $focus->column_fields["activitytype"] = "Emails";
         $focus->column_fields["date_start"] = date("Y-m-d");
         $focus->column_fields["parent_id"] = $storeid;
         $focus->column_fields["email_flag"] = "SAVED";
         $focus->column_fields["subject"] = $subject;
         $focus->column_fields["description"] = $content;
         $focus->column_fields["from_email"] = $from_email;
         $focus->column_fields["saved_toid"] = '["' . str_replace(',', '","', trim($to_email, ",")) . '"]';
         $focus->column_fields["ccmail"] = $cc;
         $focus->column_fields["bccmail"] = $bcc;
         $focus->save("Emails");
         $this->_mailRecord = $focus;
         #error_log("eMail:".$emailID);
         $emailID = $focus->id;
     } else {
         $emailID = "";
     }
     $attachments = json_decode($this->get("attachments"), true);
     if (is_array($attachments) && count($attachments) > 0) {
         // Module greifen auf Datenbank zurück. Daher vorher speichern!
         $context->save();
         foreach ($attachments as $key => $value) {
             if ($value == false) {
                 continue;
             }
             if (is_string($value)) {
                 $value = array($value, false, array());
             }
             // legacy check
             if (strpos($key, 'document#') === 0) {
                 $key = 's#' . $key;
             }
             if (strpos($key, 's#') === 0) {
                 $tmpParts = explode('#', $key, 2);
                 $specialAttachments = \Workflow\Attachment::getAttachments($tmpParts[1], $value, $context, \Workflow\Attachment::MODE_NOT_ADD_NEW_ATTACHMENTS);
                 foreach ($specialAttachments as $attachment) {
                     if ($attachment[0] === 'ID') {
                         $this->attachByAttachmentId($attachment[1]);
                     } elseif ($attachment[0] === 'PATH') {
                         $this->attachFile($attachment[1], $attachment[2], $attachment[3]);
开发者ID:cin-system,项目名称:vtigercrm-cin,代码行数:67,代码来源:WfTaskSendmail.php

示例10: array

$from_array = array("harvest@zss.com", "rain@sunshine.com", "gloom@rainyday.com", "joy@happyday.com", "success@goodjob.com");
$body_array = array("This release has close to 500 fixes in it and has gone through almost 7 rounds of validation. We think it is a stable product that you can directly use in deployment! ", "Nice to have you visit us, very nice of you. Stay for sometime and have a look at our product. I am sure you will like it", "This will take some time to fix. Can you provide me more details please?", "What a cool tool! I wish I had found it earlier. Oh it has a lot of my friends name in it too! I too can contribute. But how?", "Urgent. I need this done last week! Guys, you are the ones I am depending on. Do something!");
for ($i = 0; $i < 5; $i++) {
    $email = new Emails();
    $email->column_fields["assigned_user_id"] = $assigned_user_id;
    $rand = array_rand($num_array);
    $email->column_fields["subject"] = $esubj_array[$i];
    $email->column_fields["filename"] = $filename_array[$i];
    $email->column_fields["date_start"] = $startdate_array[$i];
    $email->column_fields["semodule"] = 'Tasks';
    $email->column_fields["activitytype"] = 'Emails';
    $email->column_fields["description"] = $body_array[$i];
    $email->column_fields["saved_toid"] = $to_array[$i];
    $focus->column_fields['ccmail'] = $cc_array[$i];
    $focus->column_fields['bccmail'] = $bcc_array[$i];
    $email->save("Emails");
    $email_ids[] = $email->id;
}
//Populate PriceBook data
$PB_array = array("Cd-R PB", "Vtiger PB", "Gator PB", "Kyple PB", "Pastor PB", "Zoho PB", "PB_100", "Per_PB", "CST_PB", "GATE_PB", "Chevron_PB", "Pizza_PB");
$Active_array = array("0", "1", "1", "0", "1", "0", "1", "1", "0", "1", "0", "1");
//$num_array = array(0,1,2,3,4);
for ($i = 0; $i < 12; $i++) {
    $pricebook = new PriceBooks();
    $rand = array_rand($num_array);
    $pricebook->column_fields["bookname"] = $PB_array[$i];
    $pricebook->column_fields["active"] = $Active_array[$i];
    $pricebook->column_fields["currency_id"] = '1';
    $pricebook->save("PriceBooks");
    $pricebook_ids[] = $pricebook->id;
}
开发者ID:nvh3010,项目名称:quancrm,代码行数:31,代码来源:PopulateSeedData.php

示例11: implode

$focus->column_fields["date_start"] = $ddate;
$focus->column_fields["time_start"] = $dtime;
//Set the flag as 'Webmails' to show up the sent date
$focus->column_fields["email_flag"] = "WEBMAIL";
//Save the To field information in vtiger_emaildetails
$all_to_ids = $email->to;
$focus->column_fields["saved_toid"] = implode(',', $all_to_ids);
//store the sent date in 'yyyy-mm-dd' format
$user_old_date_format = $current_user->date_format;
$current_user->date_format = 'yyyy-mm-dd';
$focus->column_fields["description"] = $msgData;
//to save the email details in vtiger_emaildetails vtiger_tables
$fieldid = $adb->query_result($adb->pquery('select fieldid from vtiger_field where tablename="vtiger_contactdetails" and fieldname="email" and columnname="email" and vtiger_field.presence in (0,2)', array()), 0, 'fieldid');
if (count($email->relationship) != 0) {
    $focus->column_fields['parent_id'] = $email->relationship["id"] . '@' . $fieldid . '|';
    $focus->save("Emails");
    if ($email->relationship["type"] == "Contacts") {
        add_attachment_to_contact($email->relationship["id"], $email, $focus->id);
    }
} else {
    //if relationship is not available create a contact and relate the email to the contact
    require_once 'modules/Contacts/Contacts.php';
    $contact_focus = new Contacts();
    //Populate the lastname as emailid if email doesn't have from name
    if ($email->fromname) {
        $contact_focus->column_fields['lastname'] = $email->fromname;
    } else {
        $contact_focus->column_fields['lastname'] = $email->from;
    }
    $contact_focus->column_fields['email'] = $email->from;
    $contact_focus->column_fields["assigned_user_id"] = $current_user->id;
开发者ID:casati-dolibarr,项目名称:corebos,代码行数:31,代码来源:Save.php

示例12: Emails

 /**
  * Create new Email record (and link to given record) including attachements
  */
 function __CreateNewEmail($mailrecord, $module, $linkfocus)
 {
     global $current_user, $adb;
     if (!$current_user) {
         $current_user = Users::getActiveAdminUser();
     }
     $focus = new Emails();
     $focus->column_fields['parent_type'] = $module;
     $focus->column_fields['activitytype'] = 'Emails';
     $focus->column_fields['parent_id'] = "{$linkfocus->id}@-1|";
     $focus->column_fields['subject'] = $mailrecord->_subject;
     $focus->column_fields['description'] = $mailrecord->getBodyHTML();
     $focus->column_fields['assigned_user_id'] = $linkfocus->column_fields['assigned_user_id'];
     $focus->column_fields["date_start"] = date('Y-m-d', $mailrecord->_date);
     $focus->column_fields["email_flag"] = 'MAILSCANNER';
     $from = $mailrecord->_from[0];
     $to = $mailrecord->_to[0];
     $cc = !empty($mailrecord->_cc) ? implode(',', $mailrecord->_cc) : '';
     $bcc = !empty($mailrecord->_bcc) ? implode(',', $mailrecord->_bcc) : '';
     $flag = '';
     // 'SENT'/'SAVED'
     //emails field were restructured and to,bcc and cc field are JSON arrays
     $focus->column_fields['from_email'] = $from;
     $focus->column_fields['saved_toid'] = $to;
     $focus->column_fields['ccmail'] = $cc;
     $focus->column_fields['bccmail'] = $bcc;
     $focus->save('Emails');
     $emailid = $focus->id;
     $this->log("Created [{$focus->id}]: {$mailrecord->_subject} linked it to " . $linkfocus->id);
     // TODO: Handle attachments of the mail (inline/file)
     $this->__SaveAttachements($mailrecord, 'Emails', $focus);
     return $emailid;
 }
开发者ID:jgjermeni,项目名称:corebos,代码行数:36,代码来源:MailScannerAction.php

示例13: actionRedactar

 /**
  * Muestra la formulario para redactar un email junto con una lista de usuarios
  *
  * @ruta jugadorNum12/emails/redactar
  * @redirige juagdorNum12/emails
  */
 public function actionRedactar($destinatario, $tema)
 {
     $trans = Yii::app()->db->beginTransaction();
     $yo = Usuarios::model()->findByAttributes(array('id_usuario' => Yii::app()->user->usIdent));
     $nombre_usuario = $yo->nick;
     $email = new Emails();
     $email->scenario = 'redactar';
     $this->performAjaxValidation($email);
     if (isset($_POST['Emails'])) {
         $co = $_POST['Emails']['contenido'];
         $as = $_POST['Emails']['asunto'];
         $no = $_POST['Emails']['nombre'];
         $dests = Emails::model()->sacarUsuarios($no);
         foreach ($dests as $dest) {
             $usr_dest = Usuarios::model()->findByAttributes(array('nick' => $dest));
             if ($usr_dest != null) {
                 $mail = new Emails();
                 $mail->fecha = time();
                 $mail->asunto = $as;
                 $mail->contenido = $co;
                 $mail->id_usuario_to = $usr_dest->id_usuario;
                 $mail->id_usuario_from = $yo->id_usuario;
                 if (!$mail->save()) {
                     $this->render('redactar', array('email' => $email, 'mi_aficion' => $mi_aficion, 'destinatario' => $destinatario, 'tema' => $tema));
                 }
             }
             $email = new Emails();
         }
         $trans->commit();
         $this->redirect(array('index'));
     }
     $this->render('redactar', array('email' => $email, 'destinatario' => $destinatario, 'tema' => $tema, 'nombre_usuario' => $nombre_usuario));
 }
开发者ID:rMarinf,项目名称:JugadorNum12,代码行数:39,代码来源:EmailsController.php

示例14: actionSendChallenge

    /**
     * Make a combat  with initial status.
     */
    public function actionSendChallenge()
    {
        //Check session is enable
        if (!Yii::app()->user->isGuest) {
            //Check if user is a cheater
            if ($this->user_data['knights']->name != $this->knight->name) {
                //Check if user has not a previous challenger enable
                $conditionParams = array(':status1' => Combats::STATUS_PENDING, ':status2' => Combats::STATUS_ENABLE, ':me1' => Yii::app()->user->users_id, ':me2' => Yii::app()->user->users_id, ':rival1' => $this->knight->id, ':rival2' => $this->knight->id);
                //Check if knights have a pending or enable combat
                if (!Combats::model()->exists('status != :status AND (from_knight = :knight1 AND to_knight = :rival1) OR (from_knight = :rival2 AND from_knight = :knight2)', array(':knight1' => Yii::app()->user->knights_id, ':rival1' => $this->knight->id, ':knight2' => Yii::app()->user->knights_id, ':rival2' => $this->knight->id, ':status' => Combats::STATUS_FINISHED))) {
                    //Insert a new combat
                    $combat = new Combats();
                    $combat->attributes = array('from_knight' => Yii::app()->user->knights_id, 'to_knight' => $this->knight->id, 'date' => date("Y-m-d H:i:s"), 'type' => Combats::TYPE_FRIENDLY, 'status' => Combats::STATUS_PENDING);
                    if ($combat->save()) {
                        //Insert a new combat knight event of both knights
                        $knightEventMe = new KnightsEvents();
                        $knightEventMe->attributes = array('knights_id' => Yii::app()->user->knights_id, 'type' => KnightsEvents::TYPE_COMBAT, 'identificator' => $combat->id);
                        if ($knightEventMe->save()) {
                            $knightEventRival = new KnightsEvents();
                            $knightEventRival->attributes = array('knights_id' => $this->knight->id, 'type' => KnightsEvents::TYPE_COMBAT, 'identificator' => $combat->id);
                            if ($knightEventRival->save()) {
                                //Update rows from knight events last
                                $sql = "UPDATE\n\t\t\t\t\t\t\t\t\t\tknights_events_last as k\n\t\t\t\t\t\t\t\t\t\tSET\n\t\t\t\t\t\t\t\t\t\tk.type = " . KnightsEvents::TYPE_COMBAT . ",\n\t\t\t\t\t\t\t\t\t\t\t\tk.identificator = " . $combat->id . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tk.date = '" . date('Y-m-d H:i:s') . "'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tk.id IN (\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tSELECT id FROM (\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tSELECT\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tid\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tknights_events_last\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tknights_id = " . Yii::app()->user->knights_id . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tORDER BY date ASC\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tLIMIT 1\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t) as trick\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t)";
                                //echo $sql;	die();
                                $command = Yii::app()->db->createCommand($sql);
                                //$command->bindValue( ':user_knights_id', Yii::app()->user->knights_id );
                                if ($command->query()) {
                                    $sql = "UPDATE\n\t\t\t\t\t\t\t\t\t\t\tknights_events_last\n\t\t\t\t\t\t\t\t\t\t\tSET\n\t\t\t\t\t\t\t\t\t\t\ttype = " . KnightsEvents::TYPE_COMBAT . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\tidentificator = " . $combat->id . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\ttype = " . KnightsEvents::TYPE_COMBAT . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tdate = '" . date('Y-m-d H:i:s') . "'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tid IN (\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tSELECT id FROM (\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tSELECT\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tid\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tknights_events_last\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tknights_id = " . $this->knight->id . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tORDER BY date ASC\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tLIMIT 1\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t) as trick\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t)";
                                    $command = Yii::app()->db->createCommand($sql);
                                    //$command->bindValue( ':knight_id', $this->knight->id );
                                    if ($command->execute()) {
                                        Yii::trace('[CHARACTER][sendChallenge] CHECK email');
                                        //Check email of challenge
                                        if ($knight_setting = KnightsSettings::model()->findByPk($this->knight->id)) {
                                            if ($knight_setting->emailToSendChallenge) {
                                                Yii::trace('[CHARACTER][sendChallenge] Send email');
                                                if ($knight_user = Users::model()->findByPk($this->knight->users_id)) {
                                                    Yii::trace('[CHARACTER][sendChallenge] Rival email' . $knight_user->email);
                                                    //cargamos la plantilla
                                                    $message = Yii::app()->controller->renderFile(Yii::app()->basePath . Yii::app()->params['email_templates_path'] . 'sendNewChallenge.tpl', array(), true);
                                                    // To send HTML mail, the Content-type header must be set
                                                    $headers = 'MIME-Version: 1.0' . "\r\n";
                                                    $headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";
                                                    // Additional headers
                                                    $headers .= 'To: ' . $knight_user->email . "\r\n";
                                                    $headers .= 'From: <noreply@' . Yii::app()->params->url_domain . '>' . "\r\n";
                                                    $email = new Emails();
                                                    $email->attributes = array('destination' => $knight_user->email, 'headers' => $headers, 'title' => Yii::app()->name . ': tienes un reto pendiente.', 'body' => $message, 'status' => Emails::STATUS_PENDING, 'date' => date('Y-m-d H:i:s'));
                                                    if (!$email->save()) {
                                                        Yii::trace('[CHARACTER][actionSendChallenge] No se ha podido guardar el email');
                                                    }
                                                } else {
                                                    Yii::trace('[CHARACTER][actionSendChallenge] No se ha encontrado usuario del caballero ' . $this->knight->id, 'error');
                                                }
                                            }
                                        } else {
                                            Yii::trace('[CHARACTER][actionSendChallenge] No se ha encontrado setting del caballero ' . $this->knight->id, 'error');
                                        }
                                        echo '<p>El guantazo resuena por toda la sala.</p><p>Una multitud mirando y una mejilla con 5 dedos marcados no dejan lugar a dudas. El desafio ha sido lanzado</p>
												<p>La reacción del adversario no debería hacerse esperar...</p>';
                                    } else {
                                        echo '<p>Se ha producido un error al guardar el evento rival del combate en la cache.</p>';
                                    }
                                } else {
                                    echo '<p>Se ha producido un error al guardar el evento del combate en la cache.</p>';
                                }
                                //Update events
                                /*
                                $knightEventLastMe = new KnightsEventsLast();
                                $knightEventLastMe->attributes = array(
                                		'knights_id' => Yii::app()->user->knights_id,
                                		'type' => KnightsEvents::TYPE_COMBAT,
                                		'identificator' => $combat->id,
                                		'date' => $combat->date
                                );
                                
                                $criteria = new CDbCriteria();
                                $criteria->condition = 'knights_id = :knights_id';
                                $criteria->condition = 'knights_id = :knights_id';
                                $knightEventMe = KnightsEvents::model()->find(  );
                                
                                
                                if( $knightEventLastMe->save() ){
                                $knightEventLastMe = new KnightsEventsLast();
                                $knightEventLastMe->attributes = array(
                                		'knights_id' => $this->knight->id,
                                		'type' => KnightsEvents::TYPE_COMBAT,
                                		'identificator' => $combat->id,
                                		'date' => $combat->date
                                );
                                if( $knightEventLastMe->save() ){
                                echo '<p>El guantazo resuena por toda la sala.</p><p>Una multitud mirando y una mejilla con 5 dedos marcados no dejan lugar a dudas. El desafio ha sido lanzado</p>
                                <p>La reacción del adversario no debería hacerse esperar...</p>';
                                }else{
                                echo '<p>Se ha producido un error al guardar el evento rival en la caché .</p>' ;
                                }
                                }else{
//.........这里部分代码省略.........
开发者ID:RubenDjOn,项目名称:medieval-jousting-tournaments,代码行数:101,代码来源:CharacterController.php

示例15: save

	public function save() {
		$record_id = $this -> input -> post('record_id');
		//Check if we are in editing mode first; if so, retrieve the edited record. if not, create a new one!
		if (strlen($record_id) > 0) {
			$email = Emails::getEmail($record_id);
		} else {
			$email = new Emails();
		}
		$div = $this -> session -> userdata('user_group');
		//getting the session user group
		$div2 = $this -> session -> userdata('district_province_id');
		if ($div == 1) {
			$national = "1";
			$district = "0";
			$provincial = "0";

		}

		if ($div == 2) {
			$national = "1";
			$district = "0";
			$provincial = "0";

		}

		if ($div == 3) {
			$national = "0";
			$district = "0";
			$provincial = $div2;

		}

		if ($div == 4) {

			$provincial = "0";
			$national = "0";
			$district = $div2;
		}

		$email -> email = $this -> input -> post("email");
		$email -> provincial = $provincial;
		$email -> district = $district;
		$email -> national = $national;
		$email -> valid = "1";
		$email -> stockout = $this -> input -> post("combo1");
		$email -> consumption = $this -> input -> post("combo2");
		$email -> coldchain = $this -> input -> post("combo3");
		$email -> recepient = $this -> input -> post("rep");
		$email -> number = $this -> input -> post("number");
		 $kenya=$country->country_code=trim($this->input->post("country_code"));
	    $email->number=$kenya.$this->input->post("number");
		$email -> save();
		redirect("email_management");
	}
开发者ID:EuniceManyasi,项目名称:DVI,代码行数:54,代码来源:email_management.php


注:本文中的Emails::save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。