PHP User::addNew Examples

PHP User::addNew - 7 examples found. These are the top rated real world PHP examples of User::addNew extracted from open source projects. You can rate examples to help us improve the quality of examples.
Example #1
0
 /**
  * @before _secure
  */
 public function add()
 {
     $this->seo(array("title" => "Add Account"));
     $view = $this->getActionView();
     if (RM::type() === 'POST') {
         $role = RM::post('model');
         $usr = \User::addNew($role, $this->org, $view);
         if (!$usr) {
             return;
         }
         $usr->password = sha1($usr->password);
         $usr->meta = ['skype' => RM::post('skype')];
         $usr->save();
         $view->set('message', 'Member Added!!');
     }
 }
 function add_user()
 {
     $do_api_user = new User();
     if ($this->firstname == '' || $this->lastname == '') {
         $this->setMessage("521", "First name, Last name required");
         return false;
     } elseif ($this->email == '') {
         $this->setMessage("522", "Email Id Required");
         return false;
     } elseif ($this->username == '') {
         $this->setMessage("523", "Username required.");
         return false;
     } elseif ($do_api_user->checkDuplicateUserName(trim($this->username))) {
         $this->setMessage("524", "Username is already in use.");
         return false;
     } elseif ($this->password == '') {
         $this->setMessage("525", "Password is required.");
         return false;
     } else {
         $do_api_user->addNew();
         $do_api_user->firstname = $this->firstname;
         $do_api_user->lastname = $this->lastname;
         $do_api_user->email = $this->email;
         $do_api_user->username = $this->username;
         $do_api_user->password = $this->password;
         $do_api_user->company = $this->company;
         $do_api_user->plan = $this->plan;
         $do_api_user->regdate = date("Y-m-d");
         $do_api_user->add();
         $inserted_id = $do_api_user->getPrimaryKeyValue();
         //$do_api_user->addUserAsContact($this->firstname,$this->lastname,$this->company,$this->email,$inserted_id);
         // Lets create the Contact view now
         $ContactView = new ContactView();
         $ContactView->rebuildContactUserTable($inserted_id);
         $this->email_work = $this->email;
         $this->add_contact();
         // adding the contact to the API key user
         //$do_api_user->idcontact = $this->idcontact;
         //$do_api_user->update();
         $this->setValues(array("msg" => "User Added", "stat" => "ok", "code" => "520", "iduser" => $inserted_id, "contact" => $this->idcontact));
         return true;
     }
 }
Example #3
0
 /**
  * @before _admin
  */
 public function add()
 {
     $this->seo(array("title" => "Add Advertiser"));
     $view = $this->getActionView();
     $pass = Shared\Utils::randomPass();
     $view->set("pass", $pass)->set("errors", []);
     if (RM::type() == 'POST') {
         $user = \User::addNew('advertiser', $this->org, $view);
         if (!$user) {
             return;
         }
         $user->meta = ['campaign' => ['model' => RM::post('model'), 'rate' => $this->currency(RM::post('rate')), 'coverage' => ['ALL']]];
         $user->save();
         if (RM::post("notify") == "yes") {
             Mail::send(['user' => $user, 'template' => 'advertReg', 'subject' => $this->org->name . 'Support', 'org' => $this->org]);
         }
         $user->password = sha1($user->password);
         $user->live = 1;
         $user->save();
         $this->redirect("/advertiser/manage.html");
     }
 }
 /**
  * Event Method to add Co Worker as a new user and associate the 
  * user as Co-Worker relation 
  */
 function eventAddCoWorkerOS(EventControler $evtcl)
 {
     $fields = $evtcl->fields;
     $errorpage = $evtcl->errPage;
     if ($evtcl->validation_fail == 'No') {
         // See eventRegistrationValidation() RegisteredUser.class
         $q = new sqlQuery($this->getDbCon());
         $q->query("select * from user where email = '" . $fields["email"] . "'");
         $q1 = new sqlQuery($this->getDbCon());
         $q1->query("select * from user where username = '" . $fields["username"] . "'");
         if ($q1->getNumRows() > 0) {
             $msg = "Username is already in use";
             //$errorpage = $evtcl->errorpage;
             $dispError = new Display($errorpage);
             $dispError->addParam("message", $msg);
             $evtcl->setDisplayNext($dispError);
         } elseif ($q->getNumRows() > 0) {
             $msg = "Email  already in use";
             //$errorpage = $evtcl->errorpage;
             $dispError = new Display($errorpage);
             $dispError->addParam("message", $msg);
             $evtcl->setDisplayNext($dispError);
         } else {
             // Add the new user
             $do_user_add = new User();
             $do_user_add->addNew();
             $do_user_add->firstname = $fields["firstname"];
             $do_user_add->lastname = $fields["lastname"];
             $do_user_add->email = $fields["email"];
             $do_user_add->username = $fields["username"];
             $do_user_add->password = $fields["password"];
             $do_user_add->status = "active";
             $do_user_add->add();
             $last_id = $do_user_add->getInsertId();
             //echo $last_id ;exit;
             $co_contact_view = new ContactView();
             $co_contact_view->rebuildContactUserTable($last_id);
             $this->addToCoWorkerRel($_SESSION['do_User']->iduser, $last_id);
             $this->addToCoWorkerRel($last_id, $_SESSION['do_User']->iduser);
             $this->addToAllCoWorker($last_id);
             $msg = $do_user_add->firstname . " is now one of your Co-Workers";
             $dispError = new Display($errorpage);
             $dispError->addParam("message", $msg);
             $evtcl->setDisplayNext($dispError);
         }
     }
 }
Example #5
0
 /**
  * @before _admin
  */
 public function add()
 {
     $this->seo(array("title" => "Add Publisher"));
     $view = $this->getActionView();
     $view->set("errors", []);
     if (RM::type() == 'POST') {
         $user = \User::addNew('publisher', $this->org, $view);
         if (!$user) {
             return;
         }
         if (RM::post('rate')) {
             $user->meta = ['campaign' => ['model' => RM::post('model'), 'rate' => $this->currency(RM::post('rate')), 'coverage' => ['ALL']]];
         }
         $user->save();
         if (RM::post("notify") == "yes") {
             Mail::send(['user' => $user, 'template' => 'pubRegister', 'subject' => 'Publisher at ' . $this->org->name, 'org' => $this->org, 'pass' => $user->password]);
         }
         $user->password = sha1($user->password);
         $user->live = 1;
         $user->save();
         $this->redirect("/publisher/manage.html");
     }
 }
Example #6
0
 protected function _registerUser($type, $opts = [])
 {
     $view = $this->getActionView();
     $org = $this->_org;
     $view->set('success', false);
     $usr = User::addNew($type, $org, $view);
     if ($usr === false) {
         // set view->errors to data
         $errors = $view->get('errors');
         $view->erase('errors');
         $view->set('data', ['errors' => $errors]);
         return;
     }
     $pass = $user->password;
     $usr->password = sha1($pass);
     $usr->save();
     $params = array_merge($opts, ['user' => $usr, 'org' => $org, 'pass' => $pass, 'subject' => $org->name . ' Support']);
     Shared\Mail::send($params);
     $view->set('message', ucfirst($type) . ' Added!!')->set('success', true)->set('data', (object) ['user' => User::objectArr($usr, Usr::fields())[0]]);
 }
Example #7
0
 protected function _advertiserRegister($org, $view)
 {
     $platformUrl = RM::post("platform", '');
     try {
         $platform = new \Platform(['url' => $platformUrl]);
     } catch (\Exception $e) {
         return $view->set('message', $e->getMessage());
     }
     $user = User::addNew('advertiser', $org, $view);
     if ($user === false) {
         return;
     }
     $pass = $user->password;
     $user->password = sha1($pass);
     $user->save();
     $platform->user_id = $user->_id;
     $platform->save();
     Mail::send(['user' => $user, 'org' => $this->org, 'template' => 'advertReg', 'pass' => $pass, 'subject' => $this->org->name . ' Support']);
     return $view->set('message', "Registered Successfully");
 }