function execEditGroup($userID, $groupID, $checkedUser) { if (gettype($checkedUser) != "array") { return "Wrong type of group member!"; } $checkedUser[] = $userID; $userDAO = new UserDAO(); $user = $userDAO->getUserByID($userID); if (!isValidID($groupID)) { return "Invalid group ID!"; } $groupDAO = new GroupDAO(); $group = $groupDAO->getGroupByID($groupID); if ($group === null) { return "Group doesn't exist!"; } if ($group->getOwner()->getUserID() !== $userID) { return "You are not the owner of this group!"; } $gmDAO = new GroupMemberDAO(); $gms = $gmDAO->getGroupMembersByGroup($group); foreach ($gms as $gm) { $alreadyUser = $gm->getUser(); if (in_array($alreadyUser->getUserID(), $checkedUser)) { continue; } $gmDAO->deleteGroupMember($gm); } return true; }
function verify() { if (isset($_GET["groupid"]) && isset($_GET["accept"])) { $groupID = $_GET["groupid"]; if (!isValidID($groupID)) { return; } $groupDAO = new GroupDAO(); $group = $groupDAO->getGroupByID($groupID); if ($group === null) { return; } $userDAO = new UserDAO(); $user = $userDAO->getUserByID($_SESSION["userID"]); $gmDAO = new GroupMemberDAO(); $gm = $gmDAO->getGroupMember($group, $user); if ($gm === null) { return; } $status = $gm->getAcceptStatus(); if ($status == "1") { return; } if ($_GET["accept"] == "1") { $gm->setAcceptStatus("1"); $gmDAO->updateGroupMember($gm); } elseif ($_GET["accept"] == "3") { $gmDAO->deleteGroupMember($gm); } } }
function uploadFile($userID, $groupID, $file) { $userDAO = new UserDAO(); $user = $userDAO->getUserByID($userID); if ($user->getRole()->getRoleID() == "4") { return "This user was forbidden to upload file!"; } if (!isValidID($groupID)) { return "Group id is not valid!"; } $groupDAO = new GroupDAO(); $group = $groupDAO->getGroupByID($groupID); if ($group === null) { return "Can not find this group!"; } if ($group->getActivateStatus() === "2") { return "Group is not activated!"; } $groupMemberDAO = new GroupMemberDAO(); $groupMember = $groupMemberDAO->getGroupMember($group, $user); if ($groupMember === null) { return "User didn't belong to this group!"; } if (gettype($file["error"]) == "array") { return "Only accept one file!"; } $res = isValidUploadFile($file["error"]); if ($res !== true) { return $res; } $fileType = -1; $res = isValidImage($file["name"]); if ($res === true) { $fileType = "2"; } $res = isValidFile($file["name"]); if ($res === true) { $fileType = "3"; } if ($fileType === -1) { return "Only accepts jpeg/jpg/gif/png/zip file!"; } $record = new Record($group, $user, $fileType, "temp", "1"); $recordDAO = new RecordDAO(); $recordDAO->insertRecord($record); $fileDir = "upload/"; $filePath = $fileDir . $record->getRecordID() . "_" . $file["name"]; $record->setContent($filePath); $recordDAO->updateRecord($record); if (file_exists($filePath)) { unlink($filePath); } if (!move_uploaded_file($file['tmp_name'], $filePath)) { return "Fail to move file, please contact administrator!"; } return true; }
function displayGroup($user, $tpl) { $tpl->define(array("group" => "settings/group.html", "group_tr" => "settings/group_tr.html", "group_td" => "settings/group_td.html", "group_delete" => "settings/group_delete.html")); $roleID = $user->getRole()->getRoleID(); $groupDAO = new GroupDAO(); if ($roleID === "1" || $roleID === "2") { $groups = $groupDAO->getAllGroups(); $tpl->parse("SETTINGS_GROUP_TD_DELETE", "group_delete"); } elseif ($roleID === "3") { $groups = $groupDAO->getGroupsByOwner($user); $tpl->assign("SETTINGS_GROUP_TD_DELETE", ""); } if ($groups === null) { $tpl->assign("SETTINGS_GROUP_TR", ""); } else { foreach ($groups as $group) { $currentStatus = $group->getActivateStatus(); if ($currentStatus == "1") { $tpl->assign("SETTINGS_GROUP_TD_CURR_NAME", "Activated"); $tpl->assign("SETTINGS_GROUP_TD_CHAN_STATUS", "2"); $tpl->assign("SETTINGS_GROUP_TD_CHAN_NAME", "Block"); } elseif ($currentStatus == "2") { $tpl->assign("SETTINGS_GROUP_TD_CURR_NAME", "Blocked"); $tpl->assign("SETTINGS_GROUP_TD_CHAN_STATUS", "1"); $tpl->assign("SETTINGS_GROUP_TD_CHAN_NAME", "Activate"); } $tpl->assign("SETTINGS_GROUP_GROUPID", $group->getGroupID()); $tpl->parse("SETTINGS_GROUP_TD", "group_td"); $tpl->assign("SETTINGS_GROUP_TR_GROUPNAME", $group->getGroupName()); $tpl->assign("SETTINGS_GROUP_TR_USERNAME", $group->getOwner()->getUsername()); $tpl->parse("SETTINGS_GROUP_TR", ".group_tr"); } } $tpl->parse("SETTINGS_GROUP", "group"); }
function postRecord($userID, $groupID, $messageType, $content) { $userDAO = new UserDAO(); $user = $userDAO->getUserByID($userID); if ($user->getRole()->getRoleID() == "4") { return "This user was forbidden to post!"; } if (!isValidID($groupID)) { return "Group id is not valid!"; } if (!isValidMessageType($messageType)) { return "Message type is not valid!"; } if (gettype($content) != "string" || strlen($content) > 1000) { return "Wrong type content or exceed max length(1000)!"; } if ($messageType == "4") { if (!preg_match("/^http:\\/\\//i", $content)) { return "Only accept http url!"; } $content = substr($content, 7); if ($content === "") { return "Invalid url!"; } } $groupDAO = new GroupDAO(); $group = $groupDAO->getGroupByID($groupID); if ($group === null) { return "Can not find this group!"; } if ($group->getActivateStatus() === "2") { return "Group is not activated!"; } $groupMemberDAO = new GroupMemberDAO(); $groupMember = $groupMemberDAO->getGroupMember($group, $user); if ($groupMember === null) { return "User didn't belong to this group!"; } $record = new Record($group, $user, $messageType, $content, "1"); $recordDAO = new RecordDAO(); $recordDAO->insertRecord($record); return true; }
function execCreateGroup($userID, $groupMember, $groupName) { $userDAO = new UserDAO(); $user = $userDAO->getUserByID($userID); if ($user->getRole()->getRoleID() == "4") { return "This user was forbidden to do this!"; } if (gettype($groupMember) != "array") { return "Wrong type of group member!"; } if (count($groupMember) === 0) { return "You must choose at least one group member!"; } if (count(array_unique($groupMember)) < count($groupMember)) { return "Group member has duplicate value!"; } if (in_array($userID, $groupMember)) { return "Group owner should not be a group member!"; } if ($groupName === "" || !isValidGroupName($groupName)) { return "Invalid group name, length should be between 2 to 20 and only accepts a-z, A-Z, single space!"; } $arr = array(); foreach ($groupMember as $groupUserID) { $groupUser = $userDAO->getUserByID($groupUserID); if ($groupUser === null) { return "Could not find some group members!"; } $arr[] = $groupUser; } $newGroup = new Group($user, $groupName, "1"); $groupDAO = new GroupDAO(); $groupDAO->insertGroup($newGroup); $gmDAO = new GroupMemberDAO(); $newGM = new GroupMember($newGroup, $user, "1"); $gmDAO->insertGroupMember($newGM); foreach ($arr as $gmUser) { $newGM = new GroupMember($newGroup, $gmUser, "2"); $gmDAO->insertGroupMember($newGM); } return true; }
function execAddToGroup($userID, $groupID, $adduserIDs) { $userDAO = new UserDAO(); $user = $userDAO->getUserByID($userID); if (!isValidID($groupID)) { return "Invalid group ID!"; } if (gettype($adduserIDs) != "array") { return "Wrong type of user id!"; } if (count($adduserIDs) === 0) { return "You have to choose users to add to this group!"; } foreach ($adduserIDs as $adduserID) { if (!isValidID($adduserID)) { return "Invalid user ID!"; } } $groupDAO = new GroupDAO(); $group = $groupDAO->getGroupByID($groupID); if ($group === null) { return "Group doesn't exist!"; } if ($group->getOwner()->getUserID() !== $userID) { return "You are not the owner of this group!"; } $gmDAO = new GroupMemberDAO(); foreach ($adduserIDs as $auID) { $aduser = $userDAO->getUserByID($auID); if ($aduser === null) { continue; } $gm = $gmDAO->getGroupMember($group, $aduser); if ($gm !== null) { continue; } $gm = new GroupMember($group, $aduser, "2"); $gmDAO->insertGroupMember($gm); } return true; }
function executeChange($userID, $groupID, $newStatus) { $newStatus = $newStatus; if ($newStatus !== "1" && $newStatus !== "2" && $newStatus !== "3") { return "Invalid status!"; } $userDAO = new UserDAO(); $user = $userDAO->getUserByID($userID); $groupDAO = new GroupDAO(); $group = $groupDAO->getGroupByID($groupID); if ($group === null) { return "Could not find this group!"; } if ($group->getActivateStatus() === $newStatus) { return "Old status is equal to new status, don't need to change!"; } if ($user->getRole()->getRoleID() === "3") { if ($group->getOwner()->getUserID() !== $userID) { return "You have no right to change group status!"; } if ($newStatus === "3") { return "You have no right to delete this group!"; } } if ($newStatus !== "3") { $group->setActivateStatus($newStatus); $groupDAO->updateGroup($group); } else { //delete records $recordDAO = new RecordDAO(); $recordDAO->deleteRecordsByGroup($group); //delete groupmember $gmDAO = new GroupMemberDAO(); $gmDAO->deleteGroupMembersByGroup($group); //delete group $groupDAO->deleteGroup($group); } return true; }
<?php $groupDAO = new GroupDAO(); // $app->get('/group/?', authorize() ,function() use ($groupDAO){ // header("Content-Type: application/json"); // echo json_encode($groupDAO->selectAll(), JSON_NUMERIC_CHECK); // exit(); // }); $app->get('/group/?', authorize(), function () use($groupDAO) { header("Content-Type: application/json"); echo json_encode($groupDAO->selectAllWithUsers(), JSON_NUMERIC_CHECK); exit; }); $app->get('/admin/?', authorize(), function () use($groupDAO) { header("Content-Type: application/json"); echo json_encode($groupDAO->selectAllGroups(), JSON_NUMERIC_CHECK); exit; }); $app->get('/group/:id/?', authorize(), function ($id) use($groupDAO) { header("Content-Type: application/json"); echo json_encode($groupDAO->selectById($id), JSON_NUMERIC_CHECK); exit; }); $app->get('/group/:groupname/?', authorize(), function ($groupname) use($groupDAO) { header("Content-Type: application/json"); echo json_encode($groupDAO->selectByGroupName($groupname), JSON_NUMERIC_CHECK); exit; }); $app->post('/group/?', function () use($app, $groupDAO) { header("Content-Type: application/json"); $post = $app->request->post();
/** * View list * * @author John.meng * @since version 1.0 - Dec 13, 2005 * @param datatype paramname description * @return datatype description */ function viewList() { global $__Lang__, $UrlParameter, $FlushPHPObj, $table, $page_data, $all_data, $links, $form, $smarty; $allDAO = new GroupDAO(); $all_data = $allDAO->getRows(GROUPS_TABLE); parent::viewList(); $table->setHeaderContents(0, 0, NULL); $table->setHeaderContents(0, 1, $__Lang__['langUserGroup'] . $__Lang__['langGeneralName']); $table->setHeaderContents(0, 2, $__Lang__['langUserGroup'] . $__Lang__['langGeneralDescrition']); $table->setHeaderContents(0, 3, $__Lang__['langGeneralCreateTime']); $table->setHeaderContents(0, 4, $__Lang__['langGeneralAddIP']); $table->setHeaderContents(0, 5, $__Lang__['langGeneralOperation']); if (is_array($page_data)) { foreach ($page_data as $key => $data) { $user_id = $data['GroupsID']; $table->addRow(array("<INPUT TYPE=\"checkbox\" NAME=\"CheckID[]\" value=\"{$user_id}\">", $data['GroupName'], $data['Descrition'], $data['CreateTime'], $data['AddIP'], $this->_actionBars($user_id))); } $altRow = array("class" => "grid_table_tr_alternate"); $table->altRowAttributes(1, null, $altRow); $form->addElement('static', 'fieldsAssoc', '', $table->toHtml()); $form->addElement('submit', NULL, $__Lang__['langGeneralCancel'] . $__Lang__['langGeneralSelect']); $form->addElement('hidden', 'Module', $_REQUEST['Module']); $form->addElement('hidden', 'Page', $_REQUEST['Page']); $form->addElement('hidden', 'Action', 'CancelSelected'); } $html_grib = $form->toHtml(); $smarty->assign("Main", $html_grib . $links['all']); }
require_once 'main.php'; require_once 'Connection.class.php'; require_once 'GroupDAO.class.php'; $action = isset($_GET['action']) ? $_GET['action'] : 'new'; $id = isset($_GET['id']) ? $_GET['id'] : -1; if ($action !== 'update' && $action !== 'new') { die('opció invalida'); exit; } if ($action === 'update') { /*if ($id <= 0) { die 'if no valid'; exit; }*/ $c = new Connection(); $conn = $c->getConnection(); $GroupDAO = new GroupDAO($conn); $group = $GroupDAO->select($id); } else { $group = array('id' => -1, 'name' => '', 'age' => '', 'date_start' => '', 'date_end' => '', 'location' => '', 'observations' => '', 'comments' => ''); } $title = $action === 'new' ? 'Nou grup' : 'Modificar grup'; include 'head.php'; ?> <br> <div class="row"> <h1 class="text-center"><?php echo $title; ?>
function displayIndex($userID) { $tpl = new FastTemplate("templates/"); $tpl->define(array("web_main" => "web_main.html", "web_header" => "web_header.html", "head_script" => "index/head_script.html", "user" => "index/user.html", "department" => "index/department.html", "list_item" => "index/list_item.html", "group" => "index/group.html", "comment" => "index/comment.html", "link" => "index/link.html", "image" => "index/image.html", "invitation" => "index/invitation.html", "group_option" => "index/group_option.html", "body" => "index/body.html", "web_nav" => "web_nav.html", "web_footer" => "web_footer.html")); $userDAO = new UserDAO(); $user = $userDAO->getUserByID($userID); //initial owner group $groupDAO = new GroupDAO(); $groups = $groupDAO->getGroupsByOwner($user); if ($groups === null) { $tpl->assign("INDEX_GROUP_OPTION", ""); } else { foreach ($groups as $ownerGroup) { $tpl->assign("INDEX_GROUP_OPTIONID", $ownerGroup->getGroupID()); $tpl->assign("INDEX_GROUP_OPTIONNAME", $ownerGroup->getGroupName()); $tpl->parse("INDEX_GROUP_OPTION", ".group_option"); } } //initial list item $gmDAO = new GroupMemberDAO(); $gms = $gmDAO->getGroupMembersByUser($user); if ($gms !== null) { $i = 1; $hasoneaccept = false; foreach ($gms as $gm) { if ($gm->getAcceptStatus() == "2") { continue; } $group = $gm->getGroup(); $tpl->assign("INDEX_LIST_ITEM_GROUPID", $group->getGroupID()); if ($i == 1) { $tpl->assign("INDEX_GROUP_HEADER", $group->getGroupName()); $tpl->assign("INDEX_LIST_ITEM_ACTIVE", "active"); } else { $tpl->assign("INDEX_LIST_ITEM_ACTIVE", ""); } $tpl->assign("INDEX_LIST_ITEM_SEQ", $i); $tpl->assign("INDEX_LIST_ITEM_GROUPNAME", $group->getGroupName()); $tpl->parse("INDEX_LIST_ITEM_LI", ".list_item"); $hasoneaccept = true; $i++; } if ($hasoneaccept == false) { $tpl->assign("INDEX_LIST_ITEM_LI", ""); $tpl->assign("INDEX_GROUP_HEADER", ""); } } else { $tpl->assign("INDEX_LIST_ITEM_LI", ""); $tpl->assign("INDEX_GROUP_HEADER", ""); } //initial comments $recordDAO = new RecordDAO(); if ($gms !== null) { $hasGMSflag = false; $i = 1; foreach ($gms as $gm) { if ($gm->getAcceptStatus() == "2") { continue; } $group = $gm->getGroup(); if ($i == 1) { $tpl->assign("INDEX_GROUP_HIDE", ""); } else { $tpl->assign("INDEX_GROUP_HIDE", "hide"); } $tpl->assign("INDEX_GROUP_SEQ", $i); $records = $recordDAO->getRecordsByGroup($group); if ($records === null) { $tpl->assign("INDEX_GROUP_COMMENT", ""); } else { $hasOneFlag = false; $tpl->clear("INDEX_GROUP_COMMENT"); foreach ($records as $rec) { if ($rec->getDisplayStatus() === "2") { continue; } $commentUser = $rec->getUser(); $tpl->assign("INDEX_GROUP_COMMENT_USERPHOTO", $commentUser->getPhotoURL()); $tpl->assign("INDEX_GROUP_COMMENT_USERNAME", $commentUser->getFirstName() . " " . $commentUser->getLastName()); $tpl->assign("INDEX_GROUP_COMMENT_TIME", $rec->getTime()); $type = $rec->getMessageType(); $con = $rec->getContent(); if ($type == "1") { $tpl->assign("INDEX_GROUP_COMMENT_CONTENT", htmlentities($con)); } else { if ($type == "2") { $tpl->assign("INDEX_CONTENT_IMGURL", $con); $tpl->parse("INDEX_GROUP_COMMENT_CONTENT", "image"); } else { if ($type == "3") { $tpl->assign("INDEX_GROUP_CONTENT_LINKURL", $con); $baseName = pathinfo($con, PATHINFO_BASENAME); $pos = strpos($baseName, "_"); $oriName = substr($baseName, $pos + 1); $tpl->assign("INDEX_GROUP_CONTENT_LINKNAME", htmlentities($oriName)); $tpl->parse("INDEX_GROUP_COMMENT_CONTENT", "link"); } else { if ($type == "4") { $tpl->assign("INDEX_GROUP_CONTENT_LINKURL", "http://" . rawurlencode($con)); $tpl->assign("INDEX_GROUP_CONTENT_LINKNAME", htmlentities($con)); $tpl->parse("INDEX_GROUP_COMMENT_CONTENT", "link"); } } } } $tpl->parse("INDEX_GROUP_COMMENT", ".comment"); $hasOneFlag = true; } if ($hasOneFlag == false) { $tpl->assign("INDEX_GROUP_COMMENT", ""); } } $tpl->parse("INDEX_GROUP", ".group"); $hasGMSflag = true; $i++; } if ($hasGMSflag == false) { $tpl->assign("INDEX_GROUP_COMMENT", ""); $tpl->parse("INDEX_GROUP", "group"); } } else { $tpl->assign("INDEX_GROUP_COMMENT", ""); $tpl->parse("INDEX_GROUP", "group"); } //initial department and user $result = findDepartAndUser(1, $userID); if (count($result) === 0) { $tpl->assign("INDEX_DEPART_USER", ""); } else { foreach ($result as $node) { if ($node["type"] == 1) { $tpl->assign("INDEX_DEPARTID", $node["id"]); $tpl->assign("INDEX_DEPART_NAME", $node["name"]); $tpl->parse("INDEX_DEPART_USER", ".department"); } elseif ($node["type"] == 2) { $tpl->assign("INDEX_USERID", $node["id"]); $tpl->assign("INDEX_USER_NAME", $node["name"]); $tpl->parse("INDEX_DEPART_USER", ".user"); } } } //initial annocement $flag = false; $gmArr = $gmDAO->getGroupMembersByUser($user); if ($gmArr !== null) { foreach ($gmArr as $gmPend) { if ($gmPend->getAcceptStatus() == "2") { $gmGroup = $gmPend->getGroup(); $gmOwner = $gmGroup->getOwner(); $tpl->assign("INDEX_INVITATION_OWNER", $gmOwner->getFirstName() . " " . $gmOwner->getLastName()); $tpl->assign("INDEX_INVITATION_GROUPNAME", $gmGroup->getGroupName()); $tpl->assign("INDEX_INVITATION_GROUPID", $gmGroup->getGroupID()); $tpl->parse("INDEX_INVITATION", ".invitation"); $flag = true; } } } if ($flag === false) { $tpl->assign("INDEX_INVITATION", ""); } $tpl->assign("TITLE", "Home"); $tpl->parse("WEB_HEADER", "web_header"); $tpl->parse("HEAD_SCRIPT", "head_script"); $tpl->parse("WEB_NAV", "web_nav"); $tpl->parse("BODY", ".body"); $tpl->parse("WEB_FOOTER", "web_footer"); $tpl->parse("MAIN", "web_main"); $tpl->FastPrint(); }
$search_song_themes = from_get('search_song_themes', array()); $search_ages = from_get('search_ages', array()); if ($action !== 'update' && $action !== 'new') { die('opció invalida'); exit; } $c = new Connection(); $conn = $c->getConnection(); if ($action === 'update') { $activityDAO = new ActivityDAO($conn); $workshopDAO = new WorkshopDAO($conn); $workshop = $workshopDAO->select($id); } else { $workshop = array('id' => -1, 'workshop_date' => '', 'group_id' => '', 'observations' => '', 'comments' => '', 'favourite' => '', 'age' => '', 'activity' => array()); } $groupDAO = new GroupDAO($conn); $groups = $groupDAO->getCurrentGroupsKeysAndNames(); $title = $action === 'new' ? 'Nou taller' : 'Modificar taller'; $query = "SELECT DISTINCT A.id, A.activity_name, A.description, A.goals, A.materials, A.observations, A.assesment, A.comments, A.keywords, A.types, A.song_themes, A.ages, A.timestamp, group_concat(C.name separator ', ') FROM wp_musicteach_activity A LEFT JOIN wp_musicteach_activity_song B ON A.id = B.activity_id LEFT JOIN wp_musicteach_song C ON B.song_id = C.id"; $group = " GROUP BY A.id "; $Paginator = new ActivityPaginator($conn, $query, $group, $search_string, $search_order, $search_types, $search_song_themes, $search_ages); $results = $Paginator->getData($limit, $page); include 'head.php'; ?> <div class="toggle-panel-shrink form-page"> <h1 class="text-center"><?php echo $title; ?>
<?php require_once "libraries/head.php"; require_once "libraries/class.FastTemplate.php"; if (!isLogin()) { exit; } $tpl = new FastTemplate("templates/"); $tpl->define(array("group_checked_member" => "index/group_checked_member.html")); if (isset($_POST["groupid"])) { $groupID = $_POST["groupid"]; if (!isValidID($groupID)) { return; } $userID = $_SESSION["userID"]; $groupDAO = new GroupDAO(); $group = $groupDAO->getGroupByID($groupID); if ($group === null) { return; } $gmDAO = new GroupMemberDAO(); $gms = $gmDAO->getGroupMembersByGroup($group); $flag = false; foreach ($gms as $gm) { if ($gm->getUser()->getUserID() === $userID) { continue; } $tpl->assign("INDEX_GROUP_CHECKED_USERID", $gm->getUser()->getUserID()); $tpl->assign("INDEX_GROUP_CHECKED_USERNAME", $gm->getUser()->getFirstName() . " " . $gm->getUser()->getLastName()); $tpl->parse("MAIN", ".group_checked_member"); $flag = true;
function changeGroupStatus($adminID, $groupID, $activateStatus) { $userDAO = new UserDAO(); $admin = $userDAO->getUserByID($adminID); if ($admin->getRole()->getRoleID !== 1 || $admin->getRole()->getRoleID !== 2) { return "You do not have the right to change group status!"; } $groupDAO = new GroupDAO(); $group = $groupDAO->getGroupByID($groupID); //need function if ($group->getActivateStatus() === $actuvateStatus) { return "Same Status, no need to change it!"; } $group->setActivateStatus($activateStatis); $groupDAO->updateGroup($group); //need function }
$age = $_POST['age'] or die('edat no informada'); $date_start = $_POST['date_start'] or die('data inici informada'); $date_end = $_POST['date_end'] or die('data fi informada'); $location = $_POST['location'] or die('ubicació no informada'); $observations = isset($_POST['observations']) ? $_POST['observations'] : ''; $comments = isset($_POST['comments']) ? $_POST['comments'] : ''; $group = array('id' => $id, 'name' => $name, 'age' => $age, 'date_start' => $date_start, 'date_end' => $date_end, 'location' => $location, 'comments' => $comments, 'observations' => $observations); } /* echo 'action: '.$action; echo '$group'; print_r($group); */ $c = new Connection(); $conn = $c->getConnection(); $groupDAO = new GroupDAO($conn); switch ($action) { case 'new': $insert_id = $groupDAO->create($group); break; case 'update': $groupDAO->update($group); break; case 'delete': //echo 'delete dao'.$id; exit; $groupDAO->delete($id); break; } if ($isAjax) { echo json_encode($response); exit;
require_once 'GroupDAO.class.php'; $c = new Connection(); $conn = $c->getConnection(); $limit = from_get('limit', 10); $page = from_get('page', 1); $links = from_get('links', 7); $expanded = from_get('expanded', 'on'); $search_group = from_get('search_group', ''); $search_from_date = from_get('search_from_date', ''); $search_to_date = from_get('search_to_date', ''); $search_favourite = from_get('search_favourite', ''); $search_ages = from_get('search_ages', ''); $query = "SELECT A.id, A.workshop_date, A.group_id, A.observations, A.comments, A.favourite, A.age, A.timestamp, B.name FROM wp_musicteach_workshop A JOIN wp_musicteach_group B ON A.group_id = B.id "; $group_by = ""; $conn->set_charset("utf8"); $groupDAO = new GroupDAO($conn); $groups = $groupDAO->getAllGroupsKeysAndNames(); $Paginator = new WorkshopPaginator($conn, $query, $group_by, $search_group, $search_from_date, $search_to_date, $search_favourite, $search_ages); $results = $Paginator->getData($limit, $page); if (isAjaxRequest()) { include 'include_list_workshops.php'; } else { include 'head.php'; ?> <h1 class="text-center">Cercador de tallers</h1> <div id="form-list" class="form-list" data-model="workshop"> <?php include 'include_search_workshops.php'; include 'include_list_workshops.php'; ?> </div>