Jump to content

Search the Community

Showing results for tags 'modx'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start





Website URL








Donation Link

Found 2 results

  1. Hello All: I am not very familiar with php, and need some advice about how to do something. Really appreciate a little advice. I am making a forum with MODX, it has a module for forums called Discuss. Discuss has a built-in functionality to organize new topics into questions or discussions, regardless of the board a topic is in. So when you try to make a new topic it has got two buttons, question or discussion, and if you don't choose one it throws an error (its suppose to warn you but doesn't now). I want to remove this function completely, not because of the error but just because its not suitable for my site which is not a support site. I don't care if the system considers all posts as questions, or as discussions, I just want the users to not have to choose and they can just post their topics, no buttons, no choice, and no error. Removing the buttons is easy enough, but I need to change a little php to tell the system to either not need this info, or just give it a default variable so that the user can post (I don't know the variable names right now but that is next I guess). Anyway, here is the code which will probably be clearer than the above: $discuss =& $modx->discuss; $modx->lexicon->load('discuss:post'); $fields = $hook->getValues(); unset($fields[$submitVar]); if (empty($fields['board'])) return $modx->error->failure($modx->lexicon('discuss.post_err_ns')); $board = $modx->getObject('disBoard',$fields['board']); if ($board == null) return false; My first thought was to change the "If empty" line, and tell it, if empty then return (one of the two possible values). Then, everything would be ok, it seems to me. But could I also just strip out the check for the variable completely? If I took out the three lines starting with $fields all the way to the "If empty" line, wouldn't that mean the check is gone and the post will post without concern that this value doesn't exist? Or would this set off the system somehow (as it presumably never contemplated that this value would not be there)? Or, am I barking up the wrong tree here? Really looking forward to some advice about this. Thanks in advance!
  2. Hi everyone I'm trying to generate a pdf file using TCPDF through a foreach loop. My problem is that its only generating the first entry in the array and not the second. (I'm doing this through MODx) <?php ini_set("display_errors", 1); $action = $_REQUEST['action']; switch($action) { case "generate_pdf": $id = (int) $_POST['id']; $html =''; require_once( $modx->config['base_path'].'/assets/tcpdf/examples/tcpdf_include.php'); // create new PDF document $pdf = new TCPDF('L', PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); // set document information $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor('Focus on Health'); $pdf->SetTitle('CPD Activity Record'); $pdf->SetSubject('CPD Activity Record'); $pdf->SetKeywords('CPD, Activity, Record'); // remove default header/footer $pdf->setPrintHeader(false); $pdf->setPrintFooter(false); // set default monospaced font $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); // set margins $pdf->SetMargins(5, 5, 5); $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); // set auto page breaks $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); // set image scale factor $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); // set some language-dependent strings (optional) if (@file_exists($modx->config['base_path'].'/assets/tcpdf/lang/eng.php')) { require_once($modx->config['base_path'].'/assets/tcpdf/lang/eng.php'); $pdf->setLanguageArray($l); } // --------------------------------------------------------- // set font $pdf->SetFont('helvetica', '', 9); $pdf->AddPage(); $html .= '<h1>Number of Active CEU's</h1>'; $ik = 1; $gr_arr = array(1=>'CLINICAL CEU\'S',2=>'ETHICS CEU\'S'); $data = array(); foreach($gr_arr as $group_id => $group_title){ $level1_total = 0; $level2_total = 0; $level3_total = 0; $sql = "SELECT c.*,uc.certificate_file FROM foh_conferences c LEFT JOIN foh_users_certification uc ON c.attachment_id=uc.id WHERE c.user_id = '".$_POST["id"]."' AND group_id = '".$group_id."' and (conference_accured + INTERVAL 2 YEAR) > NOW();"; $query = new xPDOCriteria($modx, $sql); $query->prepare(); $query->stmt->execute(); $data["conferences"] = array(); $conferences = array(); while($row = $query->stmt->fetch(PDO::FETCH_OBJ)) { $conferences[] = $row; $data["conferences"][] = $row; } /*$html .= '<pre>'; var_dump($conferences); $html .= '</pre>';*/ $sql2 = "SELECT e.*, e.exam_id AS renew_exam_id,s.title,s.show_level,a.pass_marks,a.total_marks,a.stotalmarks,s.accreditation_number,s.short_description, s.description,a.finished,g.title,s.number_ceu,s.group_clinical,s.group_ethics,s.date_accured,s.date_valid FROM foh_exams e INNER JOIN foh_survey s ON s.sid=e.sid LEFT JOIN foh_professions g ON s.sid = g.id INNER JOIN foh_answers a ON a.a_id=e.aid WHERE e.user_id = '".$_POST["id"]."'"; $query2 = new xPDOCriteria($modx, $sql2); $query2->prepare(); $query2->stmt->execute(); $data["exams"] = array(); $exams = array(); while($row2 = $query2->stmt->fetch(PDO::FETCH_OBJ)) { $exams[] = $row2; $data["exams"][] = $row2; } $ik++; $data["group_name"] = $group_title; $data["key"] = $group_id; /*$html .= '<pre>'; var_dump($data); $html .= '</pre>';*/ $html .= '<table cellpadding="3" cellspacing="0" border="0" style="border:1px solid #ccc;width:960px" class="ui-widget ui-corner-all"> <tr> <td colspan="9" style="text-align:center" class="ui-widget-header"> <h3>TOTAL '.$data["group_name"].'</h3> </td> </tr> <tr> <td rowspan="2" class="ui-widget-header" bgcolor="#cccccc">Name of provider</td> <td rowspan="2" class="ui-widget-header" bgcolor="#cccccc">Descriptions Of Activity</td> <td rowspan="2" class="ui-widget-header" bgcolor="#cccccc" width="100">Accreditation Number</td> <td rowspan="1" class="ui-widget-header" colspan="2" bgcolor="#cccccc">Date</td> <td rowspan="2" class="ui-widget-header" colspan="1" bgcolor="#cccccc">Level1</td> <td rowspan="2" class="ui-widget-header" colspan="1" bgcolor="#cccccc">Level2</td> <td rowspan="2" class="ui-widget-header" bgcolor="#cccccc">Level3</td> <td rowspan="2" class="ui-widget-header" bgcolor="#cccccc">Total</td> </tr> <tr> <td bgcolor="#cccccc" class="ui-widget-header">Date Accrued</td> <td bgcolor="#cccccc" class="ui-widget-header">Date Valid</td> </tr>'; foreach($data["exams"] as $exam) { if(($exam->status == 'failed'||$exam->status == 'completed') && (($exam->group_clinical==1 && $data["key"]==1) || ($exam->group_ethics==1 && $data["key"]==2)) ) { $html .= '<tr> <td>'.$exam->title.'</td> <td>'.$exam->short_description.'</td> <td>'.$exam->accreditation_number.'</td> <td align="center">'.($exam->status == 'completed'||$exam->status == 'failed'?date('Y/m/d',strtotime($exam->date_accured.'')):'----/--/--').'</td> <td align="center">'.($exam->status == 'completed'||$exam->status == 'failed'?date('Y/m/d',strtotime($exam->date_valid)):'----/--/--').'</td> <td class="center_points">'; if($exam->status == 'completed' && $exam->show_level == 1) { $html .= $exam->number_ceu; $level1_total += $exam->number_ceu; }else{ $html .= '--'; } $html .= '</td> <td class="center_points">'; if($exam->status == 'completed' && $exam->show_level == 2) { $html .= $exam->number_ceu; $level2_total += $exam->number_ceu; }else{ $html .= '--'; } $html .= '</td> <td class="center_points">'; if($exam->status == 'completed' && $exam->show_level == 3) { $html .= $exam->number_ceu; $level3_total += $exam->number_ceu; }else{ $html .= '--'; } $html .= '</td> <td class="center_points">'; if($exam->status == 'completed') { $html .= $exam->number_ceu; }else{ $html .= '--'; } $html .= '</td> </tr>'; } } foreach($data["conferences"] as $conf) { if($conf->conference_accured != '0000-00-00') { $conference_accured = strtotime($conf->conference_accured.' +2 year -1 day'); if($conference_accured > mktime()) { $html .= '<tr> <td>'.$conf->conference_name.'</td> <td>'.$conf->conference_description; if($conf->attachment_id != 0) { $html .= '<br/> <a href="'.base_url().'uploaduser_certificate/'.$conf->certificate_file.'" target="_blank">View File</a>'; } $html .= '</td> <td>'.$conf->conference_number.'</td> <td>'; if($conf->conference_accured == '0000-00-00') { $html .= '----/--/--'; }else{ $html .= date('Y/m/d',strtotime($conf->conference_accured.'')); } $html .= '</td> <td>'; if($conf->conference_accured == '0000-00-00') { $html .= '----/--/--'; }else{ $html .= date('Y/m/d',strtotime($conf->conference_accured.' +2 year -1 day')); } $html .= '</td> <td class="center_points">'; if($conf->level == 1){ $html .= $conf->points; $level1_total += $conf->points; } $html .= '</td> <td class="center_points">'; if($conf->level == 2){ $html .= $conf->points; $level2_total += $conf->points; } $html .= '</td> <td class="center_points">'; if($conf->level == 3){ $html .= $conf->points; $level3_total += $conf->points; } $html .= '</td> <td class="center_points">'.$conf->points.'</td> </tr>'; } } } $html .= '<tr> <td><b>Total Points</b></td> <td> </td> <td> </td> <td> </td> <td> </td> <td class="center_points"><b>'.$level1_total.'</b></td> <td class="center_points"><b>'.$level2_total.'</b></td> <td class="center_points"><b>'.$level3_total.'</b</td> <td class="center_points"><b>'.($level1_total+$level2_total+$level3_total).'</b></td> </tr> <tr> <td><b>Points Lapsed</b></td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td><b>Total Valid Points</b></td> <td></td> <td></td> <td></td> <td></td> <td class="center_points"><b>'.$level1_total.'</b></td> <td class="center_points"><b>'.$level2_total.'</b></td> <td class="center_points"><b>'.$level3_total.'</b></td> <td class="center_points"><b>'.($level1_total+$level2_total+$level3_total).'</b></td> </tr>'; $html .= '</table><br /><br />'; $level1_total = 0; $level2_total = 0; $level3_total = 0; } unset($data); $pdf->writeHTML($html, true, 0, true, 0); $pdf->lastPage(); $filename = $modx->config['base_path'].'/assets/report/'.$_POST["id"].'-'.date("Y-m-d H:i:s").'.pdf'; $fileatt = $pdf->Output($filename, 'F'); $json = array("message" => $fileatt); echo $fileatt; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// $fileatt1 = $filename; // Path to the file $fileatt_type = "application/pdf"; // File Type $fileatt_name = $_POST["id"]."-".date("Y-m-d H:i:s").".pdf"; // Filename that will be used for the file as the attachment $email_from = "sales@mysite.com"; // Who the email is from $email_subject = "Your attached file"; // The Subject of the email $email_message = "Here is your CPD Activity Report<br>"; $email_message .= "<br>"; // Message that the email has in it $email_to = ''; // Who the email is to $headers = "From: ".$email_from; $file = fopen($fileatt1,'rb'); $data = fread($file,filesize($fileatt1)); fclose($file); $semi_rand = md5(time()); $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; $headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\""; $email_message .= "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type:text/html; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $email_message .= "\n\n"; $data = chunk_split(base64_encode($data)); $email_message .= "--{$mime_boundary}\n" . "Content-Type: {$fileatt_type};\n" . " name=\"{$fileatt_name}\"\n" . //"Content-Disposition: attachment;\n" . //" filename=\"{$fileatt_name}\"\n" . "Content-Transfer-Encoding: base64\n\n" . $data .= "\n\n" . "--{$mime_boundary}--\n"; $ok = @mail($email_to, $email_subject, $email_message, $headers); if($ok) { $message = "Your file was successfully created and has been sent\n to the appropriate email address specified.\n Make sure to check your junk mail!\n"; } else { $message = "Sorry but the email could not be sent. Please go back and try again!"; } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// echo json_encode(array('message' => $message)); break; default: echo json_encode(array('message' => 'Unknown action')); break; } die();
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.