⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 module.class.php

📁 是一个教学内容管理系统
💻 PHP
📖 第 1 页 / 共 2 页
字号:
		return _AT(basename($this->_directoryName));	}	function getDescription($lang = 'en') {		$this->_initModuleProperties();		if (!$this->_properties) {			return;		}		if (isset($this->_properties['description'][$lang])) {			return $this->_properties['description'][$lang];		}		$description = current($this->_properties['description']);		return $description;	}	function getChildPage($page) {		if (!is_array($this->_pages)) {			return;		}		foreach ($this->_pages as $tmp_page => $item) {			if ($item['parent'] == $page) {				return $tmp_page;			}		}	}	/**	* Checks whether or not this module can be backed-up	* @access  public	* @return  boolean true if this module can be backed-up, false otherwise	* @author  Joel Kronenberg	*/	function isBackupable() {		return is_file(AT_MODULE_PATH . $this->_directoryName.'/module_backup.php');	}	function createGroup($group_id) {		if (is_file(AT_MODULE_PATH . $this->_directoryName.'/module_groups.php')) {			require_once(AT_MODULE_PATH . $this->_directoryName.'/module_groups.php');			$fn_name = basename($this->_directoryName) .'_create_group';			$fn_name($group_id);		}	}	function deleteGroup($group_id) {		$fn_name = basename($this->_directoryName) .'_delete_group';		if (!function_exists($fn_name) && is_file(AT_MODULE_PATH . $this->_directoryName.'/module_groups.php')) {			require_once(AT_MODULE_PATH . $this->_directoryName.'/module_groups.php');		} 		if (function_exists($fn_name)) {			$fn_name($group_id);		}	}	function getGroupTool() {		if (!isset($this->_group_tool)) {			return;		} 		return $this->_group_tool;	}	function isGroupable() {		return is_file(AT_MODULE_PATH . $this->_directoryName.'/module_groups.php');	}	/**	* Backup this module for a given course	* @access  public	* @param   int		$course_id	ID of the course to backup	* @param   object	$zipfile	a reference to a zipfile object	* @author  Joel Kronenberg	*/	function backup($course_id, &$zipfile) {		static $CSVExport;		if (!isset($CSVExport)) {			require_once(AT_INCLUDE_PATH . 'classes/CSVExport.class.php');			$CSVExport = new CSVExport();		}		$now = time();		if ($this->isBackupable()) {			require(AT_MODULE_PATH . $this->_directoryName . '/module_backup.php');			if (isset($sql)) {				foreach ($sql as $file_name => $table_sql) {					$content = $CSVExport->export($table_sql, $course_id);					if ($content) {						$zipfile->add_file($content, $file_name . '.csv', $now);					}				}			}			if (isset($dirs)) {				foreach ($dirs as $dir => $path) {					$path = str_replace('?', $course_id, $path);					$zipfile->add_dir($path , $dir);				}			}		}	}	/**	* Restores this module into the given course	* @access  public	* @param   int		$course_id	ID of the course to restore into	* @param   string	$version	version number of the ATutor installation used to make this backup	* @param   string	$import_dir	the path to the import directory	* @author  Joel Kronenberg	*/	function restore($course_id, $version, $import_dir) {		static $CSVImport;		if (!file_exists(AT_MODULE_PATH . $this->_directoryName.'/module_backup.php')) {			return;		}		if (!isset($CSVImport)) {			require_once(AT_INCLUDE_PATH . 'classes/CSVImport.class.php');			$CSVImport = new CSVImport();		}		require(AT_MODULE_PATH . $this->_directoryName.'/module_backup.php');		if (isset($sql)) {			foreach ($sql as $table_name => $table_sql) {				$CSVImport->import($table_name, $import_dir, $course_id, $version);			}		}		if (isset($dirs)) {			foreach ($dirs as $src => $dest) {				$dest = str_replace('?', $course_id, $dest);				copys($import_dir.$src, $dest);			}		}	}	/**	* Delete this module's course content. If $groups is specified then it will	* delete all content for the groups specified.	* @access  public	* @param   int   $course_id	ID of the course to delete	* @param   array $groups    Array of groups to delete	* @author  Joel Kronenberg	*/	function delete($course_id, $groups) {		if (is_file(AT_MODULE_PATH . $this->_directoryName.'/module_delete.php')) {			require(AT_MODULE_PATH . $this->_directoryName.'/module_delete.php');			if (function_exists(basename($this->_directoryName).'_delete')) {				$fnctn = basename($this->_directoryName).'_delete';				$fnctn($course_id);			}		}		if ($groups) {			foreach ($groups as $group_id) {				$this->deleteGroup($group_id);			}		}	}	/**	* Enables the installed module	* @access  public	* @author  Joel Kronenberg	*/	function enable() {		global $db;		$sql = 'UPDATE '. TABLE_PREFIX . 'modules SET status='.AT_MODULE_STATUS_ENABLED.' WHERE dir_name="'.$this->_directoryName.'"';		$result = mysql_query($sql, $db);	}	/**	* Sets the status to missing if the module dir doesn't exist.	* @access  public	* @param   boolean $force whether or not to force the module to be missing (used for bundled extra modules upon upgrade)	* @author  Joel Kronenberg	*/	function setIsMissing($force = false) {		global $db;		// if the directory doesn't exist then set the status to MISSING		if ($force || !is_dir(AT_MODULE_PATH . $this->_directoryName)) {			$sql = 'UPDATE '. TABLE_PREFIX . 'modules SET status='.AT_MODULE_STATUS_MISSING.' WHERE dir_name="'.$this->_directoryName.'"';			$result = mysql_query($sql, $db);		}	}	/**	* Disables the installed module	* @access  public	* @author  Joel Kronenberg	*/	function disable() {		global $db;		// remove any privileges admins, students		if ($this->_privilege > 1) {			$sql = 'UPDATE '. TABLE_PREFIX . 'course_enrollment SET `privileges`=`privileges`-'.$this->_privilege.' WHERE `privileges` > 1 AND (`privileges` & '.$this->_privilege.')<>0';			$result = mysql_query($sql, $db);		}		if ($this->_admin_privilege > 1) {			$sql = 'UPDATE '. TABLE_PREFIX . 'admins SET `privileges`=`privileges`-'.$this->_admin_privilege.' WHERE `privileges` > 1 AND (`privileges` & '.$this->_admin_privilege.')<>0';			$result = mysql_query($sql, $db);		}		$sql = 'UPDATE '. TABLE_PREFIX . 'modules SET status='.AT_MODULE_STATUS_DISABLED.' WHERE dir_name="'.$this->_directoryName.'"';		$result = mysql_query($sql, $db);		if (function_exists(basename($this->_directoryName).'_disable')) {			$fn_name = basename($this->_directoryName).'_disable';			$fn_name();		}	}	/**	* Installs the module	* @access  public	* @author  Joel Kronenberg	*/	function install() {		global $msg;		// should check if this module is already installed...		if (file_exists(AT_MODULE_PATH . $this->_directoryName . '/module_install.php')) {			require(AT_MODULE_PATH . $this->_directoryName . '/module_install.php');		}		if (!$msg->containsErrors()) {			global $db;			$sql = "SELECT MAX(`privilege`) AS `privilege`, MAX(admin_privilege) AS admin_privilege FROM ".TABLE_PREFIX."modules";			$result = mysql_query($sql, $db);			$row = mysql_fetch_assoc($result);			if (($_course_privilege === TRUE) || ((string) $_course_privilege == 'new')) {				$priv = $row['privilege'] * 2;			} else if ($_course_privilege == AT_PRIV_ADMIN) {				$priv = AT_PRIV_ADMIN;			} else {				$priv = 0;			}			if (($_admin_privilege === TRUE) || ((string) $_admin_privilege == 'new')) {				$admin_priv = $row['admin_privilege'] * 2;			} else {				$admin_priv = AT_ADMIN_PRIV_ADMIN;			}			if (isset($_cron_interval)) {				$_cron_interval = abs($_cron_interval);			} else {				$_cron_interval = 0;			}			$sql = 'INSERT INTO '. TABLE_PREFIX . 'modules VALUES ("'.$this->_directoryName.'", '.AT_MODULE_STATUS_DISABLED.', '.$priv.', '.$admin_priv.', '.$_cron_interval.', 0)';			mysql_query($sql, $db);			if (mysql_affected_rows($db) != 1) {				// in case this module has to be re-installed (because it was Missing)				$sql = 'UPDATE '. TABLE_PREFIX . 'modules SET status='.AT_MODULE_STATUS_DISABLED.' WHERE dir_name="'.$this->_directoryName.'"';				mysql_query($sql, $db);			}		}	}	function getStudentTools() {		if (!isset($this->_student_tool)) {			return FALSE;		} 		return $this->_student_tool;	}	function runCron() {		if ( ($this->_cron_last_run + ($this->_cron_interval * 60)) < time()) {			if (is_file(AT_MODULE_PATH . $this->_directoryName.'/module_cron.php')) {				require(AT_MODULE_PATH . $this->_directoryName.'/module_cron.php');				if (function_exists(basename($this->_directoryName).'_cron')) {					$fnctn = basename($this->_directoryName).'_cron';					$fnctn();				}			}			$this->updateCronLastRun();		}	}	// i'm private! update the last time the cron was run	function updateCronLastRun() {		global $db;		$sql = "UPDATE ".TABLE_PREFIX."modules SET cron_last_run=".time()." WHERE dir_name='$this->_directoryName'";		mysql_query($sql, $db);	}}?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -