Example #1
1
function getTopFive($uid)
{
    $db = new DB();
    //Create an array of all companies in format [companyname => companyid]
    $sql = "SELECT company_id, Name FROM Companies";
    $compresults = $db->execute($sql);
    $allcompanies = [];
    $compavg = [];
    while ($row = $compresults->fetch_assoc()) {
        $allcompanies[$row['Name']] = $row['company_id'];
    }
    //Find the user's priority selection
    $usrsql = "SELECT priority FROM People WHERE person_id = {$uid}";
    $usrresults = $db->execute($usrsql);
    $usrresults = $usrresults->fetch_assoc();
    $priority = $usrresults['priority'];
    //get the average rating of each company in the prioritized category and store in an array
    foreach ($allcompanies as $key => $value) {
        //hey guess what SQL can calculate column averages for you
        $avgsql = "SELECT AVG({$priority}) FROM Reviews WHERE company_id = {$value}";
        $avgresults = $db->execute($avgsql);
        $avgresults = $avgresults->fetch_assoc();
        $compavg[$key] = implode(".", $avgresults);
    }
    //sort finished array high to low and grab the top 5
    arsort($compavg);
    $topfive = array_slice($compavg, 0, 5);
    return $topfive;
}
Example #2
0
 public function setBatches($batches)
 {
     if (is_array($batches)) {
         $db = new DB();
         $db->execute("delete from session_batches where session_id = {$this->id}");
         foreach ($batches as $batch) {
             $db->execute("insert into session_batches (session_id, batch_id) values ({$this->id}, {$batch})");
         }
     }
 }
 /**
  * Renders the chart
  * @param IUser $logged_user
  * @return string
  */
 function render(IUser $logged_user)
 {
     $db_result = DB::execute("SELECT milestone_id, COUNT(*) as count FROM " . TABLE_PREFIX . "project_objects WHERE project_id = ? AND type='Task' AND state >= ? AND visibility >= ? GROUP BY milestone_id", $this->project->getId(), STATE_VISIBLE, $logged_user->getMinVisibility());
     $array_result = $db_result instanceof DBResult ? $db_result->toArrayIndexedBy('milestone_id') : false;
     if (is_foreachable($array_result)) {
         $pie_chart = new PieChart('400px', '400px', 'milestone_eta_report_pie_chart_placeholder');
         $this->serie_array = array();
         $this->milestones = array();
         // Set data for the rest
         foreach ($array_result as $serie_data) {
             $point = new ChartPoint('1', $serie_data['count']);
             $serie = new ChartSerie($point);
             if (intval($serie_data['milestone_id'])) {
                 $milestone = new RemediaMilestone(intval($serie_data['milestone_id']));
                 $label = PieChart::makeShortForPieChart($milestone->getName());
                 $this->milestones[] = $milestone;
             } else {
                 $label = lang('No Milestone');
             }
             //if
             $serie->setOption('label', $label);
             $this->serie_array[] = $serie;
         }
         //foreach
         $pie_chart->addSeries($this->serie_array);
         return $pie_chart->render();
     } else {
         return '<p class="empty_slate">' . lang('There are no milestones in this project.') . '</p>';
     }
     //if
 }
 public static function destroy($employee_id, $presence_value_date)
 {
     $sql_ar[] = 'DELETE FROM ' . TS_DB_HRM_TBNames::$employee_presence_values;
     $sql_ar[] = 'WHERE employee_id = :employee_id';
     $sql_ar[] = 'AND presence_value_date = :presence_value_date';
     return DB::execute(implode(' ', $sql_ar), array('employee_id' => $employee_id, 'presence_value_date' => $presence_value_date));
 }
Example #5
0
function getDBUsage($domainID)
{
    $dbSize = 0;
    // get database information for given domain
    $sql_param = array(':domain_id' => $domainID);
    $sql_query = "\n\t\t\tSELECT\n\t\t\t\tsqld_id, sqld_name\n\t\t\tFROM\n\t\t\t\tsql_database\n\t\t\tWHERE\n\t\t\t\tdomain_id = :domain_id\n\t\t";
    DB::prepare($sql_query);
    $sqlData = DB::execute($sql_param);
    // get usage for each database
    $sql_query = '
			SELECT 
				sum(data_length + index_length) size
			FROM 
				information_schema.tables 
			WHERE 
				table_schema = :table_schema
			GROUP BY 
				table_schema
	';
    while ($row = $sqlData->fetch()) {
        $sql_param = array(':table_schema' => $row['sqld_name']);
        DB::prepare($sql_query);
        $sqlSize = DB::execute($sql_param, true);
        $dbSize += $sqlSize[0];
    }
    return $dbSize;
}
Example #6
0
/**
 * If you need an de-activation routine run from the admin panel
 *   use the following pattern for the function:
 *
 *   <name_of_plugin>_deactivate
 *
 *  This is good for deletion of database tables etc.
 */
function reports_deactivate($purge = false)
{
    // sample drop table
    if ($purge) {
        DB::execute("DROP TABLE IF EXISTS `" . TABLE_PREFIX . "reminders`;");
    }
}
Example #7
0
/**
 * If you need an de-activation routine run from the admin panel
 *   use the following pattern for the function:
 *
 *   <name_of_plugin>_deactivate
 *
 *  This is good for deletion of database tables etc.
 */
function links_deactivate($purge = false)
{
    // sample drop table
    if ($purge) {
        DB::execute("DROP TABLE IF EXISTS `" . TABLE_PREFIX . "project_links`");
    }
}
Example #8
0
 /**
  * Write out the tags for a specific resource.
  *
  * @param int    $resource_id    The story we are tagging.
  * @param int    $channel_id     The channel id for the story we are tagging
  * @param array  $tags           An array of tags.
  *
  * @TODO: Move this to a tagger class that uses Content_Tagger
  * @return boolean
  * @throws Jonah_Exception
  */
 public function writeTags($resource_id, $channel_id, $tags)
 {
     global $conf;
     // First, make sure all tag names exist in the DB.
     $tagkeys = array();
     $insert = $this->_db->prepare('INSERT INTO jonah_tags (tag_id, tag_name) VALUES(?, ?)');
     $query = $this->_db->prepare('SELECT tag_id FROM jonah_tags WHERE tag_name = ?');
     foreach ($tags as $tag) {
         $tag = Horde_String::lower(trim($tag));
         $results = $this->_db->execute($query, $this->_db->escapeSimple($tag));
         if ($results instanceof PEAR_Error) {
             throw new Jonah_Exception($results);
         } elseif ($results->numRows() == 0) {
             $id = $this->_db->nextId('jonah_tags');
             $result = $this->_db->execute($insert, array($id, $tag));
             $tagkeys[] = $id;
         } else {
             $row = $results->fetchRow(DB_FETCHMODE_ASSOC);
             $tagkeys[] = $row['tag_id'];
         }
     }
     // Free our resources.
     $this->_db->freePrepared($insert, true);
     $this->_db->freePrepared($query, true);
     $sql = 'DELETE FROM jonah_stories_tags WHERE story_id = ' . (int) $resource_id;
     $query = $this->_db->prepare('INSERT INTO jonah_stories_tags (story_id, channel_id, tag_id) VALUES(?, ?, ?)');
     Horde::log('SQL query by Jonah_Driver_sql::writeTags: ' . $sql, 'DEBUG');
     $this->_db->query($sql);
     foreach ($tagkeys as $key) {
         $this->_db->execute($query, array($resource_id, $channel_id, $key));
     }
     $this->_db->freePrepared($query, true);
     /* @TODO We should clear at least any of our cached counts */
     return true;
 }
 function ExecuteQuery()
 {
     $this->data = array();
     $queries = ObjectController::getDashboardObjectQueries(active_project(), null, true);
     $query = '';
     foreach ($queries as $k => $q) {
         if (substr($k, -8) == 'Comments') {
             continue;
         }
         if ($query == '') {
             $query = $q;
         } else {
             $query .= " \n union \n" . $q;
         }
     }
     $ret = 0;
     $res = DB::execute($query);
     if (!$res) {
         return $ret;
     }
     $rows = $res->fetchAll();
     if (!$rows) {
         return $ret;
     }
     foreach ($rows as $row) {
         $value = 0;
         if (isset($row['quantity'])) {
             $value = $row['quantity'];
         }
         $this->data['values'][0]['labels'][] = $row['objectName'];
         $this->data['values'][0]['values'][] = $value;
     }
     //foreach
 }
 private function loadPanels($options)
 {
     if (!$this->panels) {
         $contact_pg_ids = ContactPermissionGroups::getPermissionGroupIdsByContactCSV(logged_user()->getId(), false);
         $this->panels = array();
         $sql = "\r\n\t\t\t\tSELECT * FROM " . TABLE_PREFIX . "tab_panels \r\n\t\t\t\tWHERE \r\n\t\t\t\t\tenabled = 1 AND\t\t\t\t\t\r\n\t\t\t\t\t( \t\r\n\t\t\t\t\t\tplugin_id IS NULL OR plugin_id=0 OR\r\n\t\t\t\t\t\tplugin_id IN (SELECT id FROM " . TABLE_PREFIX . "plugins WHERE is_installed = 1 AND is_activated = 1) \r\n\t\t\t\t\t)\r\n\t\t\t\t\tAND id IN (SELECT tab_panel_id FROM " . TABLE_PREFIX . "tab_panel_permissions WHERE permission_group_id IN ({$contact_pg_ids}))\r\n\t\t\t\tORDER BY ordering ASC ";
         $res = DB::execute($sql);
         while ($row = $res->fetchRow()) {
             $object = array("title" => lang($row['title']), "id" => $row['id'], "quickAddTitle" => lang($row['default_controller']), "refreshOnWorkspaceChange" => (bool) $row['refresh_on_context_change'], "defaultController" => $row['default_controller'], "defaultContent" => array("type" => "url", "data" => get_url($row['default_controller'], $row['default_action'])), "enabled" => $row['enabled'], "type" => $row['type'], "tabTip" => lang($row['title']));
             if (config_option('show_tab_icons')) {
                 $object["iconCls"] = $row['icon_cls'];
             }
             if ($row['initial_controller'] && $row['initial_action']) {
                 $object["initialContent"] = array("type" => "url", "data" => get_url($row['initial_controller'], $row['initial_action']));
             }
             if ($row['id'] == 'more-panel' && config_option('getting_started_step') >= 99) {
                 $object['closable'] = true;
                 if (!user_config_option('settings_closed')) {
                     $this->panels[] = $object;
                 }
             } else {
                 $this->panels[] = $object;
             }
         }
     }
     return $this->panels;
 }
Example #11
0
function check_login()
{
    global $db, $mem;
    if (defined('MEM') && MEM == True) {
        $mem = new Memcached('moyoj');
        $mem->setOption(Memcached::OPT_LIBKETAMA_COMPATIBLE, true);
        if (!count($mem->getServerList())) {
            $mem->addServer(MEM_HOST, MEM_PORT);
        }
    }
    $db = new DB();
    $db->init(DB_HOST, DB_USER, DB_PASS, DB_NAME);
    $db->connect();
    $admin_info = mo_read_cache('mo-admin-' . $_SESSION['aid']);
    if (!$admin_info) {
        $sql = 'SELECT `id`, `username`, `password`, `nickname`, `role` FROM `mo_admin` WHERE `id` = ? AND `role` > 0';
        $db->prepare($sql);
        $db->bind('i', $_SESSION['aid']);
        $result = $db->execute();
        if (!$result || $result[0]['password'] != $_SESSION['admin_password']) {
            unset($_SESSION['aid']);
            header("Location: login.php");
            exit(0);
        }
        mo_write_cache('mo-admin-' . $_SESSION['aid'], $result[0]);
    }
    $mo_settings = array();
    mo_load_settings();
    if (!isset($active)) {
        $active = '';
    }
}
Example #12
0
 /**
  * @return mixed
  */
 public static function CreatePDNSPass()
 {
     System_Daemon::debug('Starting "DaemonConfigDNS::createPDNSPass" subprocess.');
     $xml = simplexml_load_file(DaemonConfig::$cfg->{'CONF_DIR'} . '/tpl/EasySCP_Config_DNS.xml');
     System_Daemon::debug('Building the new pdns config file');
     $xml->{'PDNS_USER'} = 'powerdns';
     $xml->{'PDNS_PASS'} = DB::encrypt_data(DaemonCommon::generatePassword(18));
     $xml->{'HOSTNAME'} = idn_to_ascii(DaemonConfig::$cfg->{'DATABASE_HOST'});
     $handle = fopen(DaemonConfig::$cfg->{'CONF_DIR'} . '/EasySCP_Config_DNS.xml', "wb");
     fwrite($handle, $xml->asXML());
     fclose($handle);
     DaemonCommon::systemSetFilePermissions(DaemonConfig::$cfg->{'CONF_DIR'} . '/EasySCP_Config_DNS.xml', DaemonConfig::$cfg->{'ROOT_USER'}, DaemonConfig::$cfg->{'ROOT_GROUP'}, 0640);
     // Create/Update Powerdns control user account if needed
     System_Daemon::debug('Adding the PowerDNS control user');
     $sql_param = array(':PDNS_USER' => $xml->{'PDNS_USER'}, ':PDNS_PASS' => DB::decrypt_data($xml->{'PDNS_PASS'}), ':HOSTNAME' => $xml->{'HOSTNAME'});
     $sql_query = "\n\t\t\tGRANT ALL PRIVILEGES ON powerdns.* TO :PDNS_USER@:HOSTNAME IDENTIFIED BY :PDNS_PASS;\n\t\t\tFLUSH PRIVILEGES;\n\t\t";
     DB::prepare($sql_query);
     DB::execute($sql_param)->closeCursor();
     $sql_param = array(':DATABASE_USER' => DaemonConfig::$cfg->DATABASE_USER, ':DATABASE_HOST' => idn_to_ascii(DaemonConfig::$cfg->{'DATABASE_HOST'}));
     $sql_query = "\n\t\t\tGRANT ALL PRIVILEGES ON powerdns.* TO :DATABASE_USER@:DATABASE_HOST;\n\t\t\tFLUSH PRIVILEGES;\n\t\t";
     DB::prepare($sql_query);
     DB::execute($sql_param)->closeCursor();
     System_Daemon::debug('Finished "DaemonConfigDNS::createPDNSPass" subprocess.');
     return true;
 }
 /**
  * This function saves the wiki page 
  *
  * @return void
  */
 function save()
 {
     if (instance_of($this->new_revision, 'Revision')) {
         // Increase the page revision number
         $this->setColumnValue('revision', $this->getColumnValue('revision') + 1);
         // Remove any other pages in this project which have the default page status
         if ($this->isColumnModified('project_index') && $this->getColumnValue('project_index') == 1) {
             $sql = 'UPDATE ' . $this->getTableName(true) . ' SET `project_index` = 0 WHERE `project_id` = ' . $this->getProjectId();
             DB::execute($sql);
         }
         // Remove any other pages in this project which have sidebar status
         if ($this->isColumnModified('project_sidebar') && $this->getColumnValue('project_sidebar') == 1) {
             $sql = 'UPDATE ' . $this->getTableName(true) . ' SET `project_sidebar` = 0 WHERE `project_id` = ' . $this->getProjectId();
             DB::execute($sql);
         }
         // Save this page with the new revision id
         parent::save();
         // Set the revisions's page Id
         $this->new_revision->setPageId($this->getId());
         //Set the project Id
         $this->new_revision->setProjectId($this->getProjectId());
         // Set the revision number in the revision object
         $this->new_revision->setRevision($this->getColumnValue('revision'));
         // If we have made a new revision of this page, then save the revision
         $this->new_revision->save();
     } else {
         // We haven't made a new revision, so we shouldn't update this page
         return false;
     }
 }
Example #14
0
 /**
  * 
  * Returns list of Dimensions where objects with $content_object_type_id can be located
  * @param $content_object_type_id
  * @author Pepe
  */
 static function getAllowedDimensions($content_object_type_id)
 {
     $sql = "\n\t\t\tSELECT\n\t\t\t\tdotc.dimension_id AS dimension_id,\n\t\t\t\td.name as dimension_name,\n\t\t\t\td.code as dimension_code,\n\t\t\t\td.options as dimension_options,\n\t\t\t\tBIT_OR(dotc.is_required) AS is_required,\n\t\t\t\tBIT_OR(dotc.is_multiple) AS is_multiple,\n\t\t\t\td.is_manageable AS is_manageable\n\t\t\t\n\t\t\tFROM \n\t\t\t\t" . TABLE_PREFIX . "dimension_object_type_contents dotc\n\t\t\t\tINNER JOIN " . TABLE_PREFIX . "dimensions d ON d.id = dotc.dimension_id\n\t\t\t\tINNER JOIN " . TABLE_PREFIX . "object_types t ON t.id = dotc.dimension_object_type_id\n\t\t\t\n\t\t\tWHERE \n\t\t\t\tcontent_object_type_id = {$content_object_type_id}\n\t\t\tGROUP BY dimension_id\n\t\t\tORDER BY is_required DESC, dimension_name ASC\n\t\t\n\t\t";
     $dimensions = array();
     $res = DB::execute($sql);
     return $res->fetchAll();
 }
Example #15
0
 public function authenticate($password)
 {
     $auth = DB::execute("SELECT userID FROM users WHERE userID='" . ms($this->userID) . "' AND password='******'");
     if (count($auth) > 0) {
         $_SESSION['userID'] = $this->userID;
     }
 }
Example #16
0
	/**
	 * 
	 * Returns list of Dimensions where objects with $content_object_type_id can be located
	 * @param $content_object_type_id
	 * @author Pepe
	 */
	static function getAllowedDimensions($content_object_type_id) {
		$sql = "
			SELECT
				dotc.dimension_id AS dimension_id,
				d.name as dimension_name,
				d.code as dimension_code,
				d.options as dimension_options,
				BIT_OR(dotc.is_required) AS is_required,
				BIT_OR(dotc.is_multiple) AS is_multiple,
				d.is_manageable AS is_manageable
			
			FROM 
				".TABLE_PREFIX."dimension_object_type_contents dotc
				INNER JOIN ".TABLE_PREFIX."dimensions d ON d.id = dotc.dimension_id
				INNER JOIN ".TABLE_PREFIX."object_types t ON t.id = dotc.dimension_object_type_id
			
			WHERE 
				content_object_type_id = $content_object_type_id
			GROUP BY dimension_id
			ORDER BY is_required DESC, dimension_name ASC
		
		";
		$dimensions = array();
		$res= DB::execute($sql);
		return $res->fetchAll();
	}
Example #17
0
 private function checkEnvironment()
 {
     if (!file_exists(__DIR__ . $this->path)) {
         mkdir($this->path);
     }
     $this->db->execute('CREATE TABLE IF NOT EXISTS ' . $this->table . ' (`migration` varchar(64) NOT NULL PRIMARY KEY) ENGINE=MyISAM DEFAULT CHARSET=utf8;');
 }
	function addToSharingTable() {
		parent::addToSharingTable(); //  Default processing
		$oid = $this->getId() ;
		if ( $member = $this->getSelfMember() ) {
			$mid = $member->getId();
			$sql = "
				SELECT distinct(permission_group_id) as gid
			 	FROM ".TABLE_PREFIX."contact_member_permissions 
			 	WHERE member_id = $mid 
			";
			$rows = DB::executeAll($sql);
			if (is_array($rows)) {
				foreach ($rows as $row ) {
					$values = array();
					if ($gid = array_var($row, 'gid')) {					
						$values[] = "($oid, $gid)";
					}
					if (count($values) > 0) {
						$values_str = implode(",", $values);
						DB::execute("INSERT INTO ".TABLE_PREFIX."sharing_table (object_id, group_id) VALUES $values_str ON DUPLICATE KEY UPDATE object_id=object_id");
					}
				}
			}
		}
	}
Example #19
0
 /**
  * @return mixed
  */
 public static function CreateProFTPdPass()
 {
     System_Daemon::debug('Starting "DaemonConfigFTP::CreateProFTPdPass" subprocess.');
     $xml = simplexml_load_file(DaemonConfig::$cfg->{'CONF_DIR'} . '/tpl/EasySCP_Config_FTP.xml');
     System_Daemon::debug('Building the new ftp config file');
     $xml->{'DB_DATABASE'} = DB::$DB_DATABASE;
     $xml->{'DB_HOST'} = idn_to_ascii(DaemonConfig::$cfg->{'DATABASE_HOST'});
     $xml->{'FTP_USER'} = 'vftp';
     $xml->{'FTP_PASSWORD'} = DB::encrypt_data(DaemonCommon::generatePassword(18));
     $handle = fopen(DaemonConfig::$cfg->{'CONF_DIR'} . '/EasySCP_Config_FTP.xml', "wb");
     fwrite($handle, $xml->asXML());
     fclose($handle);
     System_Daemon::debug('Create/Update Proftpd SQL user data');
     $sql_param = array(':DATABASE_HOST' => $xml->{'DB_HOST'}, ':FTP_USER' => $xml->{'FTP_USER'}, ':FTP_PASSWORD' => DB::decrypt_data($xml->{'FTP_PASSWORD'}));
     $sql_query = "\n\t\t\tGRANT SELECT,INSERT,UPDATE,DELETE ON ftp_group TO :FTP_USER@:DATABASE_HOST IDENTIFIED BY :FTP_PASSWORD;\n\t\t\tGRANT SELECT,INSERT,UPDATE,DELETE ON ftp_log TO :FTP_USER@:DATABASE_HOST IDENTIFIED BY :FTP_PASSWORD;\n\t\t\tGRANT SELECT,INSERT,UPDATE,DELETE ON ftp_users TO :FTP_USER@:DATABASE_HOST IDENTIFIED BY :FTP_PASSWORD;\n\t\t\tGRANT SELECT,INSERT,UPDATE,DELETE ON quotalimits TO :FTP_USER@:DATABASE_HOST IDENTIFIED BY :FTP_PASSWORD;\n\t\t\tGRANT SELECT,INSERT,UPDATE,DELETE ON quotatallies TO :FTP_USER@:DATABASE_HOST IDENTIFIED BY :FTP_PASSWORD;\n\t\t\tFLUSH PRIVILEGES;\n\t\t";
     DB::prepare($sql_query);
     DB::execute($sql_param)->closeCursor();
     /*
     
     $xml = simplexml_load_file(DaemonConfig::$cfg->{'ROOT_DIR'} . '/../setup/config.xml');
     
     System_Daemon::debug('Create/Update Proftpd SQL user data');
     
     $sql_param = array(
     	':DATABASE_HOST'=> $xml->{'DB_HOST'},
     	':FTP_USER'		=> $xml->{'FTP_USER'},
     	':FTP_PASSWORD'	=> $xml->{'FTP_PASSWORD'}
     );
     
     $sql_query = "
     	GRANT SELECT,INSERT,UPDATE,DELETE ON ftp_group TO :FTP_USER@:DATABASE_HOST IDENTIFIED BY :FTP_PASSWORD;
     	GRANT SELECT,INSERT,UPDATE,DELETE ON ftp_log TO :FTP_USER@:DATABASE_HOST IDENTIFIED BY :FTP_PASSWORD;
     	GRANT SELECT,INSERT,UPDATE,DELETE ON ftp_users TO :FTP_USER@:DATABASE_HOST IDENTIFIED BY :FTP_PASSWORD;
     	GRANT SELECT,INSERT,UPDATE,DELETE ON quotalimits TO :FTP_USER@:DATABASE_HOST IDENTIFIED BY :FTP_PASSWORD;
     	GRANT SELECT,INSERT,UPDATE,DELETE ON quotatallies TO :FTP_USER@:DATABASE_HOST IDENTIFIED BY :FTP_PASSWORD;
     	FLUSH PRIVILEGES;
     ";
     
     DB::prepare($sql_query);
     DB::execute($sql_param)->closeCursor();
     
     if (!file_exists(DaemonConfig::$cfg->{'CONF_DIR'} . '/EasySCP_Config_FTP.xml')) {
     	$ftp = simplexml_load_file(DaemonConfig::$cfg->{'CONF_DIR'} . '/tpl/EasySCP_Config_FTP.xml');
     
     	System_Daemon::debug('Building the new ftp config file');
     
     	$ftp->{'DB_DATABASE'}	= $xml->{'DB_DATABASE'};
     	$ftp->{'DB_HOST'}		= $xml->{'DB_HOST'};
     	$ftp->{'FTP_USER'}		= $xml->{'FTP_USER'};
     	$ftp->{'FTP_PASSWORD'}	= DB::encrypt_data($xml->{'FTP_PASSWORD'});
     
     	$handle = fopen(DaemonConfig::$cfg->{'CONF_DIR'} . '/EasySCP_Config_FTP.xml', "wb");
     	fwrite($handle, $ftp->asXML());
     	fclose($handle);
     }
     */
     System_Daemon::debug('Finished "DaemonConfigFTP::CreateProFTPdPass" subprocess.');
     return true;
 }
Example #20
0
	function workspaces_update_6_7() {
		DB::execute("
			INSERT INTO `".TABLE_PREFIX."contact_config_options` (`category_name`, `name`, `default_value`, `config_handler_class`, `is_system`, `option_order`) VALUES
			 ('listing preferences', concat('lp_dim_workspaces_show_as_column'), '0', 'BoolConfigHandler', 0, 0),
			 ('listing preferences', concat('lp_dim_tags_show_as_column'), '0', 'BoolConfigHandler', 0, 0)
			ON DUPLICATE KEY UPDATE name=name;
		");
	}
Example #21
0
 /**
  * Registra en DB, Asigna un curso a un estudiante
  * @param int $curso_id
  */
 function unsetPrograma($programa_id)
 {
     $db = new DB();
     $sql = "DELETE FROM coordinadores_programas " . "WHERE coordinador_id = {$this->_id} AND programa_id = {$programa_id}";
     $db->execute($sql);
     $url = "index2.php?com=usuarios&do=view&uid=" . $this->_id;
     Elfic::cosRedirect($url);
 }
Example #22
0
 public function borrarAgenda($cid)
 {
     $sql = "DELETE FROM agendas WHERE curso_id = {$cid}";
     $db = new DB();
     if ($db->execute($sql)) {
         @unlink('files/' . $cid . ".pdf");
     }
 }
Example #23
0
/**
 * If you need an de-activation routine run from the admin panel
 *   use the following pattern for the function:
 *
 *   <name_of_plugin>_deactivate
 *
 *  This is good for deletion of database tables etc.
 */
function form_deactivate($purge = false)
{
    // sample drop table
    if ($purge) {
        DB::execute("DROP TABLE IF EXISTS `" . TABLE_PREFIX . "project_forms`;");
        DB::execute("DELETE FROM `" . TABLE_PREFIX . "application_logs` where rel_object_manager='Form';");
    }
}
Example #24
0
 public static function getTotal()
 {
     $result = DB::execute('SELECT FOUND_ROWS() AS `total`');
     if (!$result) {
         return 0;
     }
     return $result['total'];
 }
 /**
  * Execute a prepared statement
  * 
  * This function will execute a prepared statement specified by  
  * $resource (as returned by prepare()). 
  * 
  * @param int $resource The statement resource identifier (returned from prepare())
  * @param array $data A mixed array relating to the query placeholders. The number of placeholders must match the array size
  * @return bool This will always return true, as errors a thrown as exceptions
  * @throws An exception in the event of an error
  */
 public function execute($resource, $data = array())
 {
     $result = $this->conn->execute($resource, $data);
     if (DB::isError($result)) {
         throw new LoggedException($result->getMessage() . '. SQL: ' . $result->userinfo, $result->getCode(), self::module);
     }
     return true;
 }
Example #26
0
 /**
  * Registra en DB, Asigna un curso a un estudiante
  * @param int $curso_id
  */
 function unsetCurso($curso_id)
 {
     $db = new DB();
     $sql = "DELETE FROM estudiantes_cursos " . "WHERE estudiante_id = {$this->_id} AND curso_id = {$curso_id}";
     $db->execute($sql);
     $url = "index2.php?com=usuarios&do=view&uid=" . $this->_id;
     Elfic::cosRedirect($url);
 }
Example #27
0
 public function deletePregunta($pid)
 {
     $r = new Respuestas();
     $r->deleteRespuestas($pid);
     $db = new DB();
     $sql = "DELETE FROM preguntas WHERE id='{$pid}'";
     $db->execute($sql);
 }
Example #28
0
 function query($query)
 {
     $res = DB::execute($query);
     $data = array();
     while ($line = mssql_fetch_assoc($res)) {
         $data[] = $line;
     }
     return $data;
 }
Example #29
0
/**
 * If you need an de-activation routine run from the admin panel
 *   use the following pattern for the function:
 *
 *   <name_of_plugin>_deactivate
 *
 *  This is good for deletion of database tables etc.
 */
function tags_deactivate($purge = false)
{
    // sample drop table
    if ($purge) {
        $tp = TABLE_PREFIX;
        DB::execute("DROP TABLE IF EXISTS `{$tp}tags`;");
        DB::execute("DELETE FROM `{$tp}application_logs` where rel_object_manager='Tags';");
    }
}
Example #30
0
/**
 * If you need an de-activation routine run from the admin panel
 *   use the following pattern for the function:
 *
 *   <name_of_plugin>_deactivate
 *
 *  This is good for deletion of database tables etc.
 */
function wiki_deactivate($purge = false)
{
    // sample drop table
    if ($purge) {
        DB::execute("DROP TABLE IF EXISTS `" . TABLE_PREFIX . "wiki_revisions`;");
        DB::execute("DROP TABLE IF EXISTS `" . TABLE_PREFIX . "wiki_pages`;");
        DB::execute("DELETE FROM `" . TABLE_PREFIX . "application_logs` where rel_object_manager='Wiki';");
    }
}