コード例 #1
0
ファイル: script-1.php プロジェクト: Tipkin-Commons/tipkin
function lauchScript1()
{
    $managers = new Managers('pdo', PDOFactory::getMysqlConnexion());
    $reservationManager = $managers->getManagerOf('announcementreservations');
    $announcementManager = $managers->getManagerOf('announcements');
    $userManager = $managers->getManagerOf('users');
    //On supprime les réservations non-payée
    $reservationManager->deletePassedWaitingPaiement();
    $listOfReservationPassed = $reservationManager->getListOfPassed();
    $messageMail = new Mail();
    $countRervation = 0;
    foreach ($listOfReservationPassed as $reservation) {
        $reservation->setStateId(PaiementStates::CANCELED);
        $reservation->setUpdatedTime(time());
        $reservation->setKeyCheck(null);
        $reservationManager->save($reservation);
        $announce = $announcementManager->get($reservation->getAnnouncementId());
        $userOwner = $userManager->get($reservation->getUserOwnerId());
        $userSubscriber = $userManager->get($reservation->getUserSubscriberId());
        $messageMail->sendReservationSubscriberCanceled($userOwner, $userSubscriber, $announce);
        $messageMail->sendAdminReservationSubscriberCanceled($userOwner, $userSubscriber, $announce, $reservation);
        $countRervation++;
    }
    if ($countRervation > 0) {
        echo $countRervation . ' mail(s) d\'annulation de réservation envoyé(s) !';
    }
}
コード例 #2
0
ファイル: UserIdentity.php プロジェクト: kl0428/admin
 /**
  * Authenticates a user.
  * The example implementation makes sure if the username and password
  * are both 'demo'.
  * In practical applications, this should be changed to authenticate
  * against some persistent user identity storage (e.g. database).
  * @return boolean whether authentication succeeds.
  */
 public function authenticate()
 {
     $result = Managers::model()->find('name=? and is_quit=?', array($this->username, "0"));
     if ($result) {
         if ($result->password == md5($this->username . md5($this->password))) {
             $this->_id = $result->id;
             $this->errorCode = self::ERROR_NONE;
             $token = md5($result->id . $this->password);
             //Yii::app()->cache_redis->set($result->id.'.UserToken',$token);
             $store = Store::model()->findAll('manager=:id', array(':id' => $result->id));
             $store_ids = array();
             if ($store) {
                 foreach ($store as $key => $val) {
                     $store_ids[] = $val->id;
                 }
             }
             Yii::app()->user->setState('token', $token);
             Yii::app()->user->setState('info', $result);
             Yii::app()->user->setState('store', $store);
             Yii::app()->user->setState('store_ids', $store_ids);
         } else {
             $this->errorCode = self::ERROR_PASSWORD_INVALID;
         }
     } else {
         $this->errorCode = self::ERROR_USERNAME_INVALID;
     }
     return !$this->errorCode;
 }
コード例 #3
0
ファイル: manager.php プロジェクト: InfoJrUFBA/git-github
 public static function update()
 {
     static::purifier();
     if ($_POST['id'] != "" && $_POST['name'] != "" && $_POST['email'] != "") {
         $manager = new Managers($_POST);
         try {
             $manager->update($_POST['id']);
             if ($_POST['password'] != "") {
                 $manager->changePassword($_POST['id']);
             }
             $_SESSION['msg'] = 'success">Atualizado!';
             header('Location: ../views/managers');
         } catch (pdoexception $e) {
             $_SESSION['msg'] = 'fail">Erro.';
             header('Location: ../views/edit-manager');
         }
     }
 }
コード例 #4
0
ファイル: ChangeForm.php プロジェクト: kl0428/admin
 public function checkPwd($id, $pwd)
 {
     $model = Managers::model()->findByPk($id);
     $entry_pwd = md5($model->name . md5($pwd));
     if ($entry_pwd == $model->password) {
         return true;
     } else {
         $this->addError('old_pwd', '密码错误,请重新再试!');
         return false;
     }
 }
コード例 #5
0
ファイル: script-2.php プロジェクト: Tipkin-Commons/tipkin
function lauchScript2()
{
    $managers = new Managers('pdo', PDOFactory::getMysqlConnexion());
    $reservationManager = $managers->getManagerOf('announcementreservations');
    $feedbacksManager = $managers->getManagerOf('feedbacks');
    $feedbackRequestsManager = $managers->getManagerOf('feedbackrequests');
    $contactsManager = $managers->getManagerOf('contacts');
    $contactRequestsManager = $managers->getManagerOf('contactrequests');
    $usersManager = $managers->getManagerOf('users');
    $listOfPassedReservation = $reservationManager->getListOfPassedValidated();
    $messageMail = new Mail();
    foreach ($listOfPassedReservation as $reservation) {
        $listOfFeddbackRequest = $feedbackRequestsManager->getByReservationId($reservation->id());
        $listOfFeddback = $feedbacksManager->getByReservationId($reservation->id());
        if (count($listOfFeddback) + count($listOfFeddbackRequest) == 0) {
            $feedbackRequest = new FeedbackRequest();
            $feedbackRequest->setAnnounceId($reservation->getAnnouncementId());
            $feedbackRequest->setReservationId($reservation->id());
            $feedbackRequest->setUserOwnerId($reservation->getUserOwnerId());
            $feedbackRequest->setUserSubscriberId($reservation->getUserSubscriberId());
            //ENVOI POUR LE PRETEUR
            $feedbackRequest->setId(null);
            $feedbackRequest->setUserAuthorId($feedbackRequest->getUserOwnerId());
            $feedbackRequestsManager->save($feedbackRequest);
            //Envoyer un mail pour le preteur ICI
            $messageMail->sendFeedbackRequest($usersManager->get($feedbackRequest->getUserOwnerId()), $usersManager->get($feedbackRequest->getUserSubscriberId()));
            //ENVOI POUR L'EMPRUNTEUR
            $feedbackRequest->setId(null);
            $feedbackRequest->setUserAuthorId($feedbackRequest->getUserSubscriberId());
            $feedbackRequestsManager->save($feedbackRequest);
            //Envoyer un mail pour l'emprunteur ICI
            $messageMail->sendFeedbackRequest($usersManager->get($feedbackRequest->getUserSubscriberId()), $usersManager->get($feedbackRequest->getUserOwnerId()));
            //On effectue la création d'un ajout de contact s'ils ne le sont pas déjà ou qu'aucune demande n'est en attente
            $contactRequest = new ContactRequest();
            $contactRequest->setContactGroupId(ContactGroups::TIPPEURS);
            $contactRequest->setUserIdFrom($reservation->getUserSubscriberId());
            $contactRequest->setUserIdTo($reservation->getUserOwnerId());
            if (!$contactRequestsManager->isContactRequestExist($contactRequest) && !$contactsManager->isContactExistById($contactRequest->getUserIdFrom(), $contactRequest->getUserIdTo())) {
                $contactRequestsManager->save($contactRequest);
                $userFrom = $usersManager->get($contactRequest->getUserIdFrom());
                $userTo = $usersManager->get($contactRequest->getUserIdTo());
                $messageMail->sendContactRequest($userFrom, $userTo);
            }
        }
    }
}
コード例 #6
0
ファイル: ManagerController.php プロジェクト: kl0428/admin
 public function actionChange($id)
 {
     $model = new ChangeForm();
     if ($_POST['ChangeForm']) {
         $model->setAttributes($_POST['ChangeForm']);
         if ($model->validate() && $model->checkPwd($id, $_POST['ChangeForm']['old_pwd'])) {
             $userinfo = Managers::model()->findByPk($id);
             $new_password = md5($userinfo->name . md5($_POST['ChangeForm']['sure_pwd']));
             if (Managers::model()->updateByPk($id, ['password' => $new_password])) {
                 Yii::app()->user->logout();
                 Yii::app()->session->destroy();
                 $this->redirect(Yii::app()->user->loginUrl);
             }
         }
     }
     $info = Managers::model()->loadStaffModel($id);
     $this->render('change', ['model' => $model, 'info' => $info]);
 }
コード例 #7
0
ファイル: cp_cab_manager.php プロジェクト: Arikito/webking.xt
<?php

$GLOBALS['IERA_LINKS'] = array();
$GLOBALS['IERA_LINKS'][0]['title'] = "Кабинет";
$GLOBALS['IERA_LINKS'][0]['url'] = _base_url . '/cabinet/';
if (isset($_POST['id_order']) && !empty($_POST['id_order'])) {
    $id_order = intval($_POST['id_order']);
}
$Manager = new Managers();
$Manager->SetFieldsById($User->fields['id_user']);
$tpl->Assign("manager", $Manager->fields);
//*********************************
if ($User->fields['gid'] == _ACL_MANAGER_) {
    $Order = new Orders();
    if (isset($_POST['smb_cancel'])) {
        if ($Order->CancelContragentOrder($id_order)) {
            $tpl->Assign('msg', 'Заказ отменен контрагентом.');
            unset($_POST);
        } else {
            $tpl->Assign('msg', 'Информация не обновлена.');
        }
    } elseif (isset($_POST['smb_run'])) {
        if ($Order->RunContragentOrder($id_order)) {
            $tpl->Assign('msg', 'Заказ направлен к выполнению.');
            unset($_POST);
        } else {
            $tpl->Assign('msg', 'Информация не обновлена.');
        }
    }
}
//*********************************
コード例 #8
0
ファイル: StoreController.php プロジェクト: kl0428/admin
 public function actionChange()
 {
     $id = $this->_get('id');
     if ($id) {
         $accessKey = Yii::app()->params['qiniu']['accessKey'];
         $secretKey = Yii::app()->params['qiniu']['secretKey'];
         $auth = new Auth($accessKey, $secretKey);
         $bucket = 'urtime1';
         $token = $auth->uploadToken($bucket);
         $uploadMgr = new UploadManager();
         $model = Store::model()->findByPk($id);
         $bussiness_license = array();
         $images = array();
         if ($model->bussiness_license) {
             $bussiness_license = json_decode($model->bussiness_license);
         }
         if ($model->images_str) {
             $image = json_decode($model->images_str);
             if ($image) {
                 foreach ($image as $key => $val) {
                     $images = Yii::app()->params['qiniu']['host'] . $val;
                 }
             }
         }
         if ($_POST['Store']) {
             //上传logo
             if ($_FILES['image']['name'] != null) {
                 $images = array($_FILES['image']);
                 $images = $this->setImageInformation($images, $token, $uploadMgr);
                 if ($images) {
                     $_POST['Store']['image'] = $images[0];
                 }
                 unset($_FILES['image']);
             } else {
                 unset($_FILES['image']);
             }
             //上传营业执照
             if ($_FILES['bussiness_license1']['name'] != null || $_FILES['bussiness_license2']['name'] != null) {
                 if ($model->bussiness_license) {
                     if ($_FILES['bussiness_license1']['name'] != null || $_FILES['bussiness_license2']['name'] == null) {
                         $bussiness = json_decode($model->bussiness_license);
                         $images = array($_FILES['bussiness_license1']);
                         $images = $this->setImageInformation($images, $token, $uploadMgr);
                         $bussiness[0] = $images[0];
                         $_POST['Store']['bussiness_license'] = json_encode($bussiness);
                         //$images_str;
                     } else {
                         if ($_FILES['bussiness_license1']['name'] == null || $_FILES['bussiness_license2']['name'] != null) {
                             $bussiness = json_decode($model->bussiness_license);
                             $images = array($_FILES['bussiness_license2']);
                             $images = $this->setImageInformation($images, $token, $uploadMgr);
                             $bussiness[1] = $images[0];
                             $_POST['Store']['bussiness_license'] = json_encode($bussiness);
                             //$images_str;
                         } else {
                             $images = array($_FILES['bussiness_license1'], $_FILES['bussiness_license2']);
                             $images = $this->setImageInformation($images, $token, $uploadMgr);
                             if ($images) {
                                 // $images_str = implode(',',$images);
                                 $_POST['Store']['bussiness_license'] = json_encode($images);
                                 //$images_str;
                             }
                         }
                     }
                 } else {
                     $images = array($_FILES['bussiness_license1'], $_FILES['bussiness_license2']);
                     $images = $this->setImageInformation($images, $token, $uploadMgr);
                     if ($images) {
                         // $images_str = implode(',',$images);
                         $_POST['Store']['bussiness_license'] = json_encode($images);
                         //$images_str;
                     }
                 }
                 unset($_FILES['bussiness_license1']);
                 unset($_FILES['bussiness_license2']);
             } else {
                 unset($_FILES['bussiness_license1']);
                 unset($_FILES['bussiness_license2']);
             }
             //上传介绍图片
             if ($_FILES['upImage']['name'] != null) {
                 $images = $this->setImageInformation($images, $token, $uploadMgr);
                 if ($images) {
                     //$images_str = implode(',',$images);
                     $_POST['Store']['images_str'] = json_encode($images);
                     //$images_str;
                 }
             }
             $model->attributes = $_POST['Store'];
             if ($model->validate() && $model->save()) {
                 //$this->redirect('site/index');
                 Yii::app()->user->setFlash('create', '成功', '失败');
                 // Yii::app()->end();
                 $this->redirect(array('/store/view'));
             }
         }
         $is_manager = Yii::app()->user->getState("info")->authority >= 1 ? 1 : 0;
         //             var_dump($images);
         //             exit;
         $managers = Managers::model()->loadStaffAllModel();
         $this->render('change', ['model' => $model, 'bussiness_license' => $bussiness_license, 'images' => $images, 'managers' => $managers, 'is_manager' => $is_manager]);
     } else {
         $this->redirect(array('/site/index'));
     }
 }