update() 공개 메소드

public update ( array $arData = [], array $options = [] )
$arData array
$options array
 public function actionIndex()
 {
     $this->View->title = 'Mi cuenta';
     $modelAccount = new FormAccount();
     $contact = Users::find()->one(Gbox::$components->user->id);
     $modelAccount->firstname = $contact->firstname;
     $modelAccount->lastname = $contact->lastname;
     $modelAccount->email = $contact->email;
     $modelAccount->username = $contact->username;
     if (Gbox::getRequest()->isPost() && $modelAccount->load(Gbox::getRequest()->post())) {
         if (!empty($modelAccount->password) && $modelAccount->password != $modelAccount->password_confirm) {
             $modelAccount->addError('password_confirm', 'La contraseña debe coincidir con la confirmación.');
         }
         if ($modelAccount->validate()) {
             $table = new Users();
             $table->firstname = $modelAccount->firstname;
             $table->lastname = $modelAccount->lastname;
             $table->email = $modelAccount->email;
             if (!empty($modelAccount->password) && $modelAccount->password == $modelAccount->password_confirm) {
                 $table->password = crypt($modelAccount->password, '$2y$10$' . Gbox::getConfig()->params['salt']);
             }
             if ($table->update(Gbox::$components->user->id)) {
                 $msg = 'Se ha editado su cuenta con éxito.';
                 Session::set('response', ['msg' => $msg, 'type' => 'success']);
             } else {
                 Session::set('response', ['msg' => 'Ha ocurrido un error al editar su cuenta.', 'type' => 'danger']);
             }
         } else {
             Session::set('response', ['msg' => 'Ocurrió un error, revise los campos y vuelva a intentarlo.', 'type' => 'warning']);
         }
     }
     return $this->render('index', ['modelAccount' => $modelAccount]);
 }
예제 #2
0
 public function importRoster()
 {
     if (!isset($this->CURRENT_USER) or !$this->league->isManager($this->CURRENT_USER)) {
         $redirectUrl = $this->request->env('HTTP_REFERER') ?: '/';
         $this->flashMessage('You do not have permission to check this league\'s schedule.', array('alertType' => 'error'));
         return $this->redirect($redirectUrl);
     }
     $lineErrors = array();
     $errors = array();
     $playerList = array();
     $rosters = array();
     if (isset($this->request->data['draft_results'])) {
         $draft_results = $this->request->data['draft_results'];
         $draftLines = explode("\n", trim($draft_results));
         $line = 0;
         foreach ($draftLines as $l) {
             $line++;
             $fields = explode(",", $l);
             // Check field count
             if (count($fields) != 2) {
                 $errors["{$line}"] = 'Wrong number of fields';
                 continue;
             }
             $team_id = trim($fields[0]);
             $user_id = trim($fields[1]);
             if (!isset($rosters[$team_id])) {
                 $team = Teams::find($team_id);
                 if (!isset($team) or !$team->exists()) {
                     $errors["{$line}"] = "Team with the ID '{$team_id}' not found.";
                     continue;
                 }
                 if ($team->league_id != $this->league->_id) {
                     $errors["{$line}"] = "Team with the ID '{$team_id}' is not in this league.";
                     continue;
                 }
                 $rosters[$team_id] = array();
             }
             if (isset($playerList[$user_id])) {
                 $errors["{$line}"] = "User with ID '{$user_id}' has been assigned multiple times.";
                 continue;
             }
             $user = Users::find($user_id);
             if (!isset($user) or !$user->exists()) {
                 $errors["{$line}"] = "User with the ID '{$user_id}' not found.";
                 continue;
             }
             $playerList[$user_id] = new \MongoId($team_id);
             $rosters[$team_id][] = new \MongoId($user_id);
         }
         if (empty($errors)) {
             // Assign Team Rosters
             foreach ($rosters as $team_id => $roster) {
                 $conditions = array('_id' => new \MongoId($team_id));
                 $query = array('$set' => array('players' => $roster));
                 Teams::update($query, $conditions);
             }
             // Assign Player Teams
             foreach ($playerList as $user_id => $team_id) {
                 $conditions = array('_id' => new \MongoId($user_id));
                 $query = array('$addToSet' => array('teams' => $team_id));
                 Users::update($query, $conditions);
             }
             $this->flashMessage('Roster Imported Successfully!', array('alertType' => 'success'));
             return $this->redirect(array('Leagues::view', 'id' => $this->league->_id));
         }
     } else {
         $draft_results = '';
     }
     return compact('draft_results', 'errors', 'rosters');
 }
예제 #3
0
 /**
  * @param Users $user
  * @return bool
  */
 public function update(Users $user)
 {
     if ($user->getId() == 1 && session('user')->getId() != 1) {
         return false;
     }
     return $user->update();
 }
예제 #4
0
 public function updatex()
 {
     $email = $this->request->query['email'];
     $phone = $this->request->query['phoneNumber'];
     $code = $this->request->query['code'];
     $walletid = $this->request->query['walletid'];
     $passphrase = $this->request->query['passphrase'];
     $privkey = $this->request->query['privkey'];
     $ip = $this->request->query['ip'];
     $greencoinAddress = $this->request->query['greencoinAddress'];
     $user = Users::find("first", array("conditions" => array("walletid" => $walletid)));
     $greencoin = new Greencoin('http://' . GREENCOIN_WALLET_SERVER . ':' . GREENCOIN_WALLET_PORT, GREENCOIN_WALLET_USERNAME, GREENCOIN_WALLET_PASSWORD);
     $createWallet = $greencoin->importprivkey($privkey, $walletid, false);
     $filename = "Wallet_" + gmdate('Y-m-d_H-i-s', time()) . ".txt";
     $dumpwallet = $greencoin->dumpwallet($filename);
     $printdata = array('email' => $email, 'phone' => $phone, 'walletid' => $walletid, 'passphrase' => $passphrase, 'code' => $code, 'privkey' => $privkey, 'greencoinAddress' => $greencoinAddress, 'ip' => $ip, 'DateTime' => new \MongoDate());
     //create all QR Codes
     $qrcode = new QRcode();
     $qrcode->png($passphrase, QR_OUTPUT_DIR . "XGCWallet-" . $walletid . "-passphrase.png", 'H', 7, 2);
     $qrcode->png($walletid, QR_OUTPUT_DIR . "XGCWallet-" . $walletid . "-walletid.png", 'H', 7, 2);
     $qrcode->png($code, QR_OUTPUT_DIR . "XGCWallet-" . $walletid . "-code.png", 'H', 7, 2);
     $qrcode->png($privkey, QR_OUTPUT_DIR . "XGCWallet-" . $walletid . "-privkey.png", 'H', 7, 2);
     $qrcode->png($greencoinAddress, QR_OUTPUT_DIR . "XGCWallet-" . $walletid . "-greencoinAddress.png", 'H', 7, 2);
     // send email for password and QRCode print --------- start
     $view = new View(array('paths' => array('template' => '{:library}/views/{:controller}/{:template}.{:type}.php', 'layout' => '{:library}/views/layouts/{:layout}.{:type}.php')));
     echo $view->render('all', compact('printdata'), array('controller' => 'print', 'template' => 'walletsetup', 'type' => 'pdf', 'layout' => 'print'));
     // sending email to the users
     /////////////////////////////////Email//////////////////////////////////////////////////
     $function = new Functions();
     $compact = array('data' => $printdata);
     $from = array(NOREPLY => "noreply@" . COMPANY_URL);
     $email = $email;
     $function->sendEmailTo($email, $compact, 'ex', 'setupwd', "XGCWallet - important document", $from, '', '', '', null);
     $attach = QR_OUTPUT_DIR . 'XGCWallet-' . $printdata['walletid'] . "-Wallet" . ".pdf";
     $function->sendEmailTo($email, $compact, 'ex', 'setup', "XGCWallet - important document", $from, '', '', '', $attach);
     /////////////////////////////////Email//////////////////////////////////////////////////
     // send email for password and QRCode print --------- end
     $data = array('greencoinAddress.0' => $greencoinAddress);
     $conditions = array("walletid" => $walletid);
     Users::update($data, $conditions);
     //delete all QR code files from the server
     if ($handle = opendir(QR_OUTPUT_DIR)) {
         while (false !== ($entry = readdir($handle))) {
             if ($entry != "." && $entry != "..") {
                 if (strpos($entry, $printdata['walletid'])) {
                     unlink(QR_OUTPUT_DIR . $entry);
                 }
             }
         }
         closedir($handle);
     }
     Users::update($data, $conditions);
     return $this->render(array('json' => array('success' => 1)));
 }