Ejemplo n.º 1
0
 /**
  * function to activate the cpanel login for customer
  * @param integer $idcontacts
  * @param string $email
  * @param integer $idorganization
  * @return string
  */
 public function activate_cpanel_login($idcontacts, $email, $idorganization)
 {
     $pass = CommonUtils::generate_random_string(10);
     $qry = "\n\t\tselect * from `cpanel_user`\n\t\twhere \n\t\t`idcontacts` = ?\n\t\tand `idorganization` = ?\n\t\t";
     $stmt = $this->getDbConnection()->executeQuery($qry, array($idcontacts, $idorganization));
     if ($stmt->rowCount() > 0) {
         $data = $stmt->fetch();
         $id = $data['idcpanel_user'];
         $upd = "\n\t\t\tupdate `cpanel_user`\n\t\t\tset \n\t\t\t`email` = ?,\n\t\t\t`password` = ?\n\t\t\twhere `idcpanel_user` = ?\n\t\t\t";
         $this->getDbConnection()->executeQuery($upd, array($email, md5($pass), $id));
     } else {
         $ins = "\n\t\t\tinsert into `cpanel_user`\n\t\t\t(`email`,`password`,`idcontacts`,`idorganization`)\n\t\t\tvalues\n\t\t\t(?,?,?,?)\n\t\t\t";
         $this->getDbConnection()->executeQuery($ins, array($email, md5($pass), $idcontacts, $idorganization));
     }
     return $pass;
 }