Skip to main content

Posts

Showing posts with the label MXAE-API

[MXAE] How to DELETE a record

Delete a record using MXAE-API function deleteOneRecord($programCodeOrID, $recId) { $delete = false; $program = new mxProgram; $program->getBy(array('id' => $programCodeOrID, 'code' => array($programCodeOrID, '=', 'OR'))); $ac = $program->getArticle($recId); $delete = $ac->del(); //echo $ac->client; return $delete; }

How to update an article

$program = new mxProgram; $program->getBy(array('id' => $programCodeOrID, 'code' => array($programCodeOrID, '=', 'OR'))); $article = $program->getArticle($recId); $article->fieldname1 = $value1; $article->fieldname2 = $value2; $articleupdate = $article->update();

How to insert an article

$program = new mxProgram; $program->getBy(array('id' => $programCodeOrID, 'code' => array($programCodeOrID, '=', 'OR'))); $article = $program->getEmptyArticle(); $article->fieldname1 = $value1; $article->fieldname2 = $value2; $articleAdd = $program->addArticle($article);

How to get the article's file/blob attribute

$fieldset = new mxFieldset(); $fieldset->getBy( array( 'frmid' => $formsetid, 'column' => 'attachment1')); if( 0 == $fieldset->id) {   echo 'error: ' . $fieldset->getLastErrorMessage();   return; } $blob = $article->getBlobData( $fieldset, true); if( $blob && 0 id ) {   $blob->contenttype data size filename <==== The original file name when being uploaded. }

[MXAE] How To Get Articles (And Print Out)

To list an article (or articles) using MXAE-API. //one article $program = new mxProgram; $program->getBy(array('id' => $programCodeOrID, 'code' => array($programCodeOrID, '=', 'OR'))); $article = $program->getArticle($recId); //articles (more than one) $arcs = $prog->getArticles(array('category' => $fVal, 'orderby' => ' foreach($arcs as $theArcs) { echo "{$theArcs->nationality}"; echo "{$theArcs->dateofbirth->format("d-m-Y")}"; //date format } //total articles $totalArticle = $program->getArticleCount();

To list program/subchannel under a channel

--php opening-- //get all program/sub-channel function getAllProgramsUnderThisChannel($channelCodeOrID) { $ids = array(); $channel = new mxChannel; $channel->getBy(array('id' => $channelCodeOrID, 'code' => array($channelCodeOrID, '=', 'OR'))); $programs = $channel->getAllPrograms(); foreach($programs as $program) { $ids[] = $program->code; } $subchannels = $channel->getAllChildChannels(); foreach($subchannels as $subchannel) { $tids = $this->getAllProgramsUnderThisChannel($subchannel->id); $pids = array_merge($ids, $tids); $ids = $pids; } return $ids; } --php closing--

How to reset user's password

--php opening-- $tempPswd = rand(2593, 4999); $newPswd = "cimb".$tempPswd; $memObj = $_mxPub->factory(null,MX_OBJECT_MEMBER); $memArc = $memObj->getAll(array('username' => $username)); foreach ($memArc as $member) { $usrMail = $member->email; $usrName = $member->username; echo "Your new password had been send to your email ".$member->email; $member->resetUsernamePassword($member->username,$newPswd); } --php closing--

How to add a member

--php opening-- //add new user and set password $memberObj = new mxMember; $memberObj->$_POST['object']['username']; $memberObj->setPassword($_POST['object']['password'], ''); if (!$memberObj->add()) echo "Error adding member"; else echo "New member added"; //update member info including password $memberObj = new mxMember; $members = $memberObj->getAll(array('username'=>$_POST['object']['username'])); if (count($members) > 0){ foreach ($members as $member) { $member->username = $_POST['object']['username']; $member->updatePassword($_POST['object']['password'], ''); if (!$member->update()) echo "Error update member"; else echo "Member updated"; } } --php closing--