$ind_all_catalogs_list[] = $current_eschool_val; //} } } else { $ind_ctlg_crse_count[$product_list_key] = 0; } } $cert_ctlg_crse_lists = array(); $cert_ctlg_crse_count = array(); $cert_all_catalogs_list = array(); $cert_all_catalogs_count = 0; foreach ($cert_products_list as $product_list_key => $product_list_val) { $institution_name = $product_list_key; $mhr_institution_obj = $CFG->current_app->selectFromMhrTable('institution', 'name', $institution_name, true); if ($mhr_institution_obj) { $mhr_institution = new GcrMhrInstitution($mhr_institution_obj, $CFG->current_app); $potential_eschools = array(); $current_eschools = array(); // Check if users do not exist on the eschool, and get potential users in properly formatted form $eschools = $mhr_institution->getEschools(); if ($eschools) { foreach ($eschools as $eschool) { $current_eschools[$eschool->getShortName()] = $eschool->getFullName(); } } $eschools = $CFG->current_app->getMnetEschools(); if ($eschools) { foreach ($eschools as $eschool) { if (!array_key_exists($eschool->getShortName(), $current_eschools)) { $potential_eschools[$eschool->getShortName()] = $eschool->getFullName(); }
public function executeCoursesList(sfWebRequest $request) { global $CFG; $CFG->current_app->requireMahara(); $params = array(); $lib_ctlg_courses_list = array(); $catalog_courses_count = array(); $current_eschools = array(); foreach (GcrCourseList::getParameterList() as $key => $value) { $params[$key] = $request->getParameter($key); } $params["list_size"] = 4; if (isset($params["lib_id"]) && !empty($params["lib_id"])) { $mhr_institution_obj = $CFG->current_app->selectFromMhrTable('institution', 'name', $params["lib_id"], true); if ($mhr_institution_obj) { $mhr_institution = new GcrMhrInstitution($mhr_institution_obj, $CFG->current_app); $potential_eschools = array(); $current_eschools = array(); // Check if users do not exist on the eschool, and get potential users in properly formatted form $eschools = $mhr_institution->getEschools(); if ($eschools) { foreach ($eschools as $eschool) { $current_eschools[$eschool->getShortName()] = $eschool->getFullName(); } } $eschools = $CFG->current_app->getMnetEschools(); if ($eschools) { foreach ($eschools as $eschool) { if (!array_key_exists($eschool->getShortName(), $current_eschools)) { $potential_eschools[$eschool->getShortName()] = $eschool->getFullName(); } } } asort($potential_eschools); asort($current_eschools); foreach ($current_eschools as $current_eschool_key => $current_eschool_val) { $sub_params = array(); $sub_params = $params; $sub_params["mode"] = "Eschool"; $sub_params["mode_id"] = $current_eschool_key; $courses_list = new GcrCourseList($sub_params, $CFG->current_app); $lib_ctlg_courses_list[$current_eschool_key] = $courses_list->getCourseList(); $catalog_courses_count[$current_eschool_key] = $this->getHTMLCoursesCount($current_eschool_key); } } } else { $courses_list = new GcrCourseList($params, $CFG->current_app); //$this->lib_courses_list[] = array($params["mode_id"]=>$courses_list->getCourseList()); $lib_ctlg_courses_list[$params["mode_id"]] = $courses_list->getCourseList(); $catalog_courses_count[$params["mode_id"]] = $this->getHTMLCoursesCount($params["mode_id"]); $eschools = $CFG->current_app->getMnetEschools(); if ($eschools) { foreach ($eschools as $eschool) { $current_eschools[$eschool->getShortName()] = $eschool->getFullName(); } } } $this->lib_courses_list = $lib_ctlg_courses_list; $this->catalog_courses_count = $catalog_courses_count; $this->current_eschools = $current_eschools; $this->request_params = $params; $this->getResponse()->setTitle('Courses'); sfConfig::set('sf_escaping_strategy', false); }
public function executeCronUpdateCoursesCount(sfWebRequest $request) { global $CFG; $CFG->current_app->requireMahara(); $this->params = $request->getGetParameters(); $platform_short_name = $CFG->current_app->getShortName(); $product_type = isset($this->params['type']) ? $this->params['type'] : ""; // gets all available schools $eschool_array = array(); $catalog_courses_count = array(); foreach ($CFG->current_app->getMnetEschools() as $eschool) { //if (GcrEschoolTable::authorizeEschoolAccess($eschool, true)) { $eschool_array[$eschool->getFullName()] = $eschool; //} } ksort($eschool_array); // gets catalog-wise courses count foreach ($eschool_array as $eschool) { $catalog_courses_count[$eschool->getShortName()] = $this->getHTMLCoursesCount($eschool->getShortName()); } // gets all products list $all_products = GcrProductsTable::getAllProducts($platform_short_name, $product_type); $all_products_details = array(); foreach ($all_products as $product) { $all_products_details[$product->getShortName()]["id"] = $product->getId(); $all_products_details[$product->getShortName()]["product_type_id"] = $product->getProductTypeId(); $all_products_details[$product->getShortName()]["short_name"] = $product->getShortName(); $all_products_details[$product->getShortName()]["institution_short_name"] = $product->getInstitutionShortName(); $all_products_details[$product->getShortName()]["catalog_short_name"] = $product->getCatalogShortName(); $all_products_details[$product->getShortName()]["platform_short_name"] = $product->getPlatformShortName(); if ($product->getProductTypeId() == 2 || $product->getProductTypeId() == 3) { $is_exist = GcrInstitutionCatalogCoursesTable::checkIsExist($product->getInstitutionShortName(), $product->getCatalogShortName(), $product->getPlatformShortName()); $ctlg_crses_count = isset($catalog_courses_count[$product->getCatalogShortName()]) ? $catalog_courses_count[$product->getCatalogShortName()] : 0; if ($is_exist == 0) { $cron_obj = new GcrInstitutionCatalogCourses(); $cron_obj->setPlatformShortName($product->getPlatformShortName()); $cron_obj->setInstitutionShortName($product->getInstitutionShortName()); $cron_obj->setCatalogShortName($product->getCatalogShortName()); $cron_obj->setProductTypeId($product->getProductTypeId()); $cron_obj->setCoursesCount($ctlg_crses_count); $cron_obj->save(); } else { Doctrine_Query::create()->update('GcrInstitutionCatalogCourses')->set('courses_count', '?', $ctlg_crses_count)->where('institution_short_name = ?', $product->getInstitutionShortName())->andWhere('platform_short_name = ?', $product->getPlatformShortName())->andWhere('catalog_short_name = ?', $product->getCatalogShortName())->andWhere('product_type_id = ?', $product->getProductTypeId())->execute(); } } else { if ($product->getProductTypeId() == 1) { $institution_name = $product->getInstitutionShortName(); $mhr_institution_obj = $CFG->current_app->selectFromMhrTable('institution', 'name', $institution_name, true); if ($mhr_institution_obj) { $mhr_institution = new GcrMhrInstitution($mhr_institution_obj, $CFG->current_app); $current_eschools = array(); $eschools = $mhr_institution->getEschools(); if ($eschools) { foreach ($eschools as $eschool) { $current_eschools[$eschool->getShortName()] = $eschool->getFullName(); } } asort($current_eschools); foreach ($current_eschools as $current_eschool_key => $current_eschool_val) { if (stripos(strtolower($current_eschool_val), "(*)") === false && stripos(strtolower($current_eschool_val), "(\$)") === false) { $params = array(); $params["start_index"] = 0; $params["mode"] = "Eschool"; $params["mode_id"] = $current_eschool_key; $this->course_list = new GcrCourseList($params, $CFG->current_app); $catalog_courses_count[$current_eschool_key] = $this->course_list->getCoursesCount(); $is_exist = GcrInstitutionCatalogCoursesTable::checkIsExist($product->getInstitutionShortName(), $current_eschool_key, $product->getPlatformShortName()); $ctlg_crses_count = isset($catalog_courses_count[$current_eschool_key]) ? $catalog_courses_count[$current_eschool_key] : 0; if ($is_exist == 0) { $cron_obj = new GcrInstitutionCatalogCourses(); $cron_obj->setPlatformShortName($product->getPlatformShortName()); $cron_obj->setInstitutionShortName($product->getInstitutionShortName()); $cron_obj->setCatalogShortName($current_eschool_key); $cron_obj->setProductTypeId($product->getProductTypeId()); $cron_obj->setCoursesCount($ctlg_crses_count); $cron_obj->save(); } else { Doctrine_Query::create()->update('GcrInstitutionCatalogCourses')->set('courses_count', '?', $ctlg_crses_count)->where('institution_short_name = ?', $product->getInstitutionShortName())->andWhere('platform_short_name = ?', $product->getPlatformShortName())->andWhere('catalog_short_name = ?', $current_eschool_key)->andWhere('product_type_id = ?', $product->getProductTypeId())->execute(); } } } } } } } /* print "<pre>"; print_r($catalog_courses_count); //print_r($all_products_details); print "</pre>"; */ echo "<br>Completed<br>"; exit; }
function remove_submit(Pieform $form, $values) { global $CFG; $mhr_institution_obj = $CFG->current_app->selectFromMhrTable('institution', 'name', $values['institution_name'], true); if (!$mhr_institution_obj) { $CFG->current_app->gcError('MhrInstitution does not exist with name ' . $values['institution_name'], 'gcdatabaseerror'); } $mhr_institution = new GcrMhrInstitution($mhr_institution_obj, $CFG->current_app); foreach ($values['eschools'] as $eschool) { $eschool = GcrEschoolTable::getEschool($eschool); $mhr_institution->removeEschool($eschool); } redirect("/artefact/eschooladmin/institutioncatalogs.php?institution=" . $values['institution_name']); }