code
stringlengths 12
2.05k
| label_name
stringclasses 5
values | label
int64 0
4
|
---|---|---|
$percent = round($percent, 0);
} else {
$percent = round($percent, 2); // school default
}
if ($ret == '%')
return $percent;
if (!$_openSIS['_makeLetterGrade']['grades'][$grade_scale_id])
$_openSIS['_makeLetterGrade']['grades'][$grade_scale_id] = DBGet(DBQuery('SELECT TITLE,ID,BREAK_OFF FROM report_card_grades WHERE SYEAR=\'' . $cp[1]['SYEAR'] . '\' AND SCHOOL_ID=\'' . $cp[1]['SCHOOL_ID'] . '\' AND GRADE_SCALE_ID=\'' . $grade_scale_id . '\' ORDER BY BREAK_OFF IS NOT NULL DESC,BREAK_OFF DESC,SORT_ORDER'));
foreach ($_openSIS['_makeLetterGrade']['grades'][$grade_scale_id] as $grade) {
if ($does_breakoff == 'Y' ? $percent >= $programconfig[$staff_id][$course_period_id . '-' . $grade['ID']] && is_numeric($programconfig[$staff_id][$course_period_id . '-' . $grade['ID']]) : $percent >= $grade['BREAK_OFF'])
return $ret == 'ID' ? $grade['ID'] : $grade['TITLE'];
}
} | Base | 1 |
public function store($zdb)
{
try {
$values = array(
self::PK => $this->id,
'model_fields' => serialize($this->fields)
);
if (!isset($this->id) || $this->id == '') {
//we're inserting a new model
unset($values[self::PK]);
$this->creation_date = date("Y-m-d H:i:s");
$values['model_creation_date'] = $this->creation_date;
$insert = $zdb->insert(self::TABLE);
$insert->values($values);
$results = $zdb->execute($insert);
if ($results->count() > 0) {
return true;
} else {
throw new \Exception(
'An error occurred inserting new import model!'
);
}
} else {
//we're editing an existing model
$update = $zdb->update(self::TABLE);
$update->set($values);
$update->where(self::PK . '=' . $this->id);
$zdb->execute($update);
return true;
}
} catch (Throwable $e) {
Analog::log(
'Something went wrong storing import model :\'( | ' .
$e->getMessage() . "\n" . $e->getTraceAsString(),
Analog::ERROR
);
throw $e;
}
} | Base | 1 |
public static function isHadParent($parent='', $menuid = ''){
if(isset($menuid)){
$where = " AND `menuid` = '{$menuid}'";
}else{
$where = '';
}
if(isset($parent) && $parent != ''){
$parent = " `parent` = '{$parent}'";
}else{
$parent = '1';
}
$sql = sprintf("SELECT * FROM `menus` WHERE %s %s", $parent, $where);
$menu = Db::result($sql);
return $menu;
}
| Base | 1 |
public static function background($item_type, $item_id, $color)
{
global $DB;
global $website;
global $user;
$DB->execute('
INSERT INTO nv_notes
(id, website, user, item_type, item_id, background, note, date_created)
VALUES
( 0, :website, :user, :item_type, :item_id, :background, :note, :date_created )',
array(
':website' => $website->id,
':user' => value_or_default($user->id, 0),
':item_type' => value_or_default($item_type, ''),
':item_id' => value_or_default($item_id, 0),
':background' => value_or_default($color, ""),
':note' => "",
':date_created' => time()
)
);
$background = $DB->query_single(
'background',
'nv_notes',
'website = '.$website->id.'
AND item_type = '.protect($item_type).'
AND item_id = '.protect($item_id).'
ORDER BY date_created DESC'
);
// TODO: purge old grid notes when current background is empty or transparent
// => remove all empty notes
// NOT REALLY NEEDED, just save the item grid notes history, let the user remove at will
if(empty($background) || $background=='transparent')
{
$DB->execute('
DELETE FROM nv_notes
WHERE website = '.$website->id.'
AND item_type = '.protect($item_type).'
AND item_id = '.protect($item_id).'
AND note = ""
');
}
}
| Base | 1 |
function update($vars, &$errors) {
if (!$vars['grace_period'])
$errors['grace_period'] = __('Grace period required');
elseif (!is_numeric($vars['grace_period']))
$errors['grace_period'] = __('Numeric value required (in hours)');
elseif ($vars['grace_period'] > 8760)
$errors['grace_period'] = sprintf(
__('%s cannot be more than 8760 hours'),
__('Grace period')
);
if (!$vars['name'])
$errors['name'] = __('Name is required');
elseif (($sid=SLA::getIdByName($vars['name'])) && $sid!=$vars['id'])
$errors['name'] = __('Name already exists');
if ($errors)
return false;
$this->name = $vars['name'];
$this->grace_period = $vars['grace_period'];
$this->notes = Format::sanitize($vars['notes']);
$this->flags =
($vars['isactive'] ? self::FLAG_ACTIVE : 0)
| (isset($vars['disable_overdue_alerts']) ? self::FLAG_NOALERTS : 0)
| (isset($vars['enable_priority_escalation']) ? self::FLAG_ESCALATE : 0)
| (isset($vars['transient']) ? self::FLAG_TRANSIENT : 0);
if ($this->save())
return true;
if (isset($this->id)) {
$errors['err']=sprintf(__('Unable to update %s.'), __('this SLA plan'))
.' '.__('Internal error occurred');
} else {
$errors['err']=sprintf(__('Unable to add %s.'), __('this SLA plan'))
.' '.__('Internal error occurred');
}
return false;
} | Base | 1 |
protected function stat($path) {
if ($path === false || is_null($path)) {
return false;
}
$is_root = ($path == $this->root);
if ($is_root) {
$rootKey = md5($path);
if (!isset($this->sessionCache['rootstat'])) {
$this->sessionCache['rootstat'] = array();
}
if (! $this->isMyReload()) {
// need $path as key for netmount/netunmount
if (isset($this->sessionCache['rootstat'][$rootKey])) {
if ($ret = $this->sessionCache['rootstat'][$rootKey]) {
return $ret;
}
}
}
}
$ret = isset($this->cache[$path])
? $this->cache[$path]
: $this->updateCache($path, $this->convEncOut($this->_stat($this->convEncIn($path))));
if ($is_root) {
$this->sessionCache['rootstat'][$rootKey] = $ret;
$this->session->set($this->id, $this->sessionCache);
}
return $ret;
} | Base | 1 |
public function setUp()
{
$client = $this->getHttpClient();
$request = $this->getHttpRequest();
$this->request = new RestCreateSubscriptionRequest($client, $request);
$this->request->initialize(array(
'name' => 'Test Subscription',
'description' => 'Test Billing Subscription',
'startDate' => new \DateTime(),
'planId' => 'ABC-123',
'payerDetails' => array(
'payment_method' => 'paypal',
),
));
} | Base | 1 |
public function editTitle() {
global $user;
$file = new expFile($this->params['id']);
if ($user->id==$file->poster || $user->isAdmin()) {
$file->title = $this->params['newValue'];
$file->save();
$ar = new expAjaxReply(200, gt('Your title was updated successfully'), $file);
} else {
$ar = new expAjaxReply(300, gt("You didn't create this file, so you can't edit it."));
}
$ar->send();
} | Base | 1 |
public function update_version() {
// get the current version
$hv = new help_version();
$current_version = $hv->find('first', 'is_current=1');
// check to see if the we have a new current version and unset the old current version.
if (!empty($this->params['is_current'])) {
// $db->sql('UPDATE '.DB_TABLE_PREFIX.'_help_version set is_current=0');
help_version::clearHelpVersion();
}
expSession::un_set('help-version');
// save the version
$id = empty($this->params['id']) ? null : $this->params['id'];
$version = new help_version();
// if we don't have a current version yet so we will force this one to be it
if (empty($current_version->id)) $this->params['is_current'] = 1;
$version->update($this->params);
// if this is a new version we need to copy over docs
if (empty($id)) {
self::copydocs($current_version->id, $version->id);
}
// let's update the search index to reflect the current help version
searchController::spider();
flash('message', gt('Saved help version').' '.$version->version);
expHistory::back();
} | Base | 1 |
public static function cleanLink($fulllink)
{
if(substr($fulllink, -1) == '/') $fulllink = substr($fulllink, 0, -1);
return $fulllink;
} | Base | 1 |
$escapedArgument .= '^%"'.substr($part, 1, -1).'"^%';
} else {
// escape trailing backslash
if ('\\' === substr($part, -1)) {
$part .= '\\';
}
$quote = true;
$escapedArgument .= $part;
}
}
if ($quote) {
$escapedArgument = '"'.$escapedArgument.'"';
}
return $escapedArgument;
} | Class | 2 |
public function withQuery($query)
{
if (!is_string($query) && !method_exists($query, '__toString')) {
throw new \InvalidArgumentException(
'Query string must be a string'
);
}
$query = (string) $query;
if (substr($query, 0, 1) === '?') {
$query = substr($query, 1);
}
$query = $this->filterQueryAndFragment($query);
if ($this->query === $query) {
return $this;
}
$new = clone $this;
$new->query = $query;
return $new;
} | Base | 1 |
public function confirm()
{
$project = $this->getProject();
$swimlane = $this->getSwimlane();
$this->response->html($this->helper->layout->project('swimlane/remove', array(
'project' => $project,
'swimlane' => $swimlane,
)));
} | Base | 1 |
public function confirm()
{
$project = $this->getProject();
$tag_id = $this->request->getIntegerParam('tag_id');
$tag = $this->tagModel->getById($tag_id);
$this->response->html($this->template->render('project_tag/remove', array(
'tag' => $tag,
'project' => $project,
)));
} | Base | 1 |
protected function _filePutContents($path, $content) {
$res = false;
if ($this->tmp) {
$local = $this->getTempFile();
if (@file_put_contents($local, $content, LOCK_EX) !== false
&& ($fp = @fopen($local, 'rb'))) {
clearstatcache();
$res = ftp_fput($this->connect, $path, $fp, $this->ftpMode($path));
@fclose($fp);
}
file_exists($local) && @unlink($local);
}
return $res;
} | Base | 1 |
public function manage() {
expHistory::set('manageable', $this->params);
// build out a SQL query that gets all the data we need and is sortable.
$sql = 'SELECT b.*, c.title as companyname, f.expfiles_id as file_id ';
$sql .= 'FROM '.DB_TABLE_PREFIX.'_banner b, '.DB_TABLE_PREFIX.'_companies c , '.DB_TABLE_PREFIX.'_content_expFiles f ';
$sql .= 'WHERE b.companies_id = c.id AND (b.id = f.content_id AND f.content_type="banner")';
$page = new expPaginator(array(
'model'=>'banner',
'sql'=>$sql,
'order'=>'title',
'page'=>(isset($this->params['page']) ? $this->params['page'] : 1),
'controller'=>$this->params['controller'],
'action'=>$this->params['action'],
'src'=>$this->loc->src,
'columns'=>array(
gt('Title')=>'title',
gt('Company')=>'companyname',
gt('Impressions')=>'impressions',
gt('Clicks')=>'clicks'
)
));
assign_to_template(array(
'page'=>$page
));
} | Base | 1 |
public function backup($type='json')
{
global $DB;
global $website;
$out = array();
$DB->query('
SELECT * FROM nv_paths
WHERE website = '.protect($website->id),
'object'
);
$out = $DB->result();
if($type='json')
$out = json_encode($out);
return $out;
}
| Base | 1 |
public function disable()
{
$this->checkCSRFParam();
$project = $this->getProject();
$swimlane_id = $this->request->getIntegerParam('swimlane_id');
if ($this->swimlaneModel->disable($project['id'], $swimlane_id)) {
$this->flash->success(t('Swimlane updated successfully.'));
} else {
$this->flash->failure(t('Unable to update this swimlane.'));
}
$this->response->redirect($this->helper->url->to('SwimlaneController', 'index', array('project_id' => $project['id'])));
} | Class | 2 |
function manage() {
global $db;
expHistory::set('manageable', $this->params);
// $classes = array();
$dir = BASE."framework/modules/ecommerce/billingcalculators";
if (is_readable($dir)) {
$dh = opendir($dir);
while (($file = readdir($dh)) !== false) {
if (is_file("$dir/$file") && substr("$dir/$file", -4) == ".php") {
include_once("$dir/$file");
$classname = substr($file, 0, -4);
$id = $db->selectValue('billingcalculator', 'id', 'calculator_name="'.$classname.'"');
if (empty($id)) {
// $calobj = null;
$calcobj = new $classname();
if ($calcobj->isSelectable() == true) {
$obj = new billingcalculator(array(
'title'=>$calcobj->name(),
// 'user_title'=>$calcobj->title,
'body'=>$calcobj->description(),
'calculator_name'=>$classname,
'enabled'=>false));
$obj->save();
}
}
}
}
}
$bcalc = new billingcalculator();
$calculators = $bcalc->find('all');
assign_to_template(array(
'calculators'=>$calculators
));
} | Base | 1 |
self::removeLevel($kid->id);
}
}
| Base | 1 |
public function getBranches()
{
if (null === $this->branches) {
$branches = array();
$bookmarks = array();
$this->process->execute('hg branches', $output, $this->repoDir);
foreach ($this->process->splitLines($output) as $branch) {
if ($branch && Preg::isMatch('(^([^\s]+)\s+\d+:([a-f0-9]+))', $branch, $match)) {
$branches[$match[1]] = $match[2];
}
}
$this->process->execute('hg bookmarks', $output, $this->repoDir);
foreach ($this->process->splitLines($output) as $branch) {
if ($branch && Preg::isMatch('(^(?:[\s*]*)([^\s]+)\s+\d+:(.*)$)', $branch, $match)) {
$bookmarks[$match[1]] = $match[2];
}
}
// Branches will have preference over bookmarks
$this->branches = array_merge($bookmarks, $branches);
}
return $this->branches;
} | Base | 1 |
public static function totalCat($vars) {
$posts = Db::result("SELECT `id` FROM `cat` WHERE `type` = '{$vars}'");
$npost = Db::$num_rows;
return $npost;
}
| Base | 1 |
public function getPurchaseOrderByJSON() {
if(!empty($this->params['vendor'])) {
$purchase_orders = $this->purchase_order->find('all', 'vendor_id=' . $this->params['vendor']);
} else {
$purchase_orders = $this->purchase_order->find('all');
}
echo json_encode($purchase_orders);
} | Class | 2 |
public function link($target, $link)
{
if (! windows_os()) {
return symlink($target, $link);
}
$mode = $this->isDirectory($target) ? 'J' : 'H';
exec("mklink /{$mode} \"{$link}\" \"{$target}\"");
} | Base | 1 |
public function subscriptions() {
global $db;
expHistory::set('manageable', $this->params);
// make sure we have what we need.
if (empty($this->params['key'])) expQueue::flashAndFlow('error', gt('The security key for account was not supplied.'));
if (empty($this->params['id'])) expQueue::flashAndFlow('error', gt('The subscriber id for account was not supplied.'));
// verify the id/key pair
$sub = new subscribers($this->params['id']);
if (empty($sub->id)) expQueue::flashAndFlow('error', gt('We could not find any subscriptions matching the ID and Key you provided.'));
// get this users subscriptions
$subscriptions = $db->selectColumn('expeAlerts_subscribers', 'expeAlerts_id', 'subscribers_id='.$sub->id);
// get a list of all available E-Alerts
$ealerts = new expeAlerts();
assign_to_template(array(
'subscriber'=>$sub,
'subscriptions'=>$subscriptions,
'ealerts'=>$ealerts->find('all')
));
} | Base | 1 |
function json_decode($json, $assoc=null)
{
return array();
} | Base | 1 |
foreach ($nodes as $node) {
if ((($perm == 'view' && $node->public == 1) || expPermissions::check($perm, expCore::makeLocation('navigation', '', $node->id))) && !in_array($node->id, $ignore_ids)) {
if ($node->active == 1) {
$text = str_pad('', ($depth + ($full ? 1 : 0)) * 3, '.', STR_PAD_LEFT) . $node->name;
} else {
$text = str_pad('', ($depth + ($full ? 1 : 0)) * 3, '.', STR_PAD_LEFT) . '(' . $node->name . ')';
}
$ar[$node->id] = $text;
foreach (self::levelDropdownControlArray($node->id, $depth + 1, $ignore_ids, $full, $perm, $addstandalones, $addinternalalias) as $id => $text) {
$ar[$id] = $text;
}
}
}
| Base | 1 |
function delete_recurring() {
$item = $this->event->find('first', 'id=' . $this->params['id']);
if ($item->is_recurring == 1) { // need to give user options
expHistory::set('editable', $this->params);
assign_to_template(array(
'checked_date' => $this->params['date_id'],
'event' => $item,
));
} else { // Process a regular delete
$item->delete();
}
}
| Class | 2 |
public function rename(){
if($this->request->isMethod('POST')){
if(\Storage::move($this->request->input('old_file'), $this->request->input('new_file'))){
if($this->request->ajax()){
return response()->json(['success' => trans('File successfully renamed!')]);
}
}else{
if($this->request->ajax()){
return response()->json(['danger' => trans('message.something_went_wrong')]);
}
}
}
} | Base | 1 |
public static function exist ($vars) {
if(file_exists(GX_THEME.THEME.'/'.$vars.'.php')) {
return true;
}else{
return false;
}
}
| Base | 1 |
public function get_bitly () {
$file = urldecode (join ('/', func_get_args ()));
$link = $this->controller->absolutize ('/files/' . $file);
return BitlyLink::lookup ($link);
} | Base | 1 |
public function autocomplete() {
return;
global $db;
$model = $this->params['model'];
$mod = new $model();
$srchcol = explode(",",$this->params['searchoncol']);
/*for ($i=0; $i<count($srchcol); $i++) {
if ($i>=1) $sql .= " OR ";
$sql .= $srchcol[$i].' LIKE \'%'.$this->params['query'].'%\'';
}*/
// $sql .= ' AND parent_id=0';
//eDebug($sql);
//$res = $mod->find('all',$sql,'id',25);
$sql = "select DISTINCT(p.id), p.title, model, sef_url, f.id as fileid from ".$db->prefix."product as p INNER JOIN ".$db->prefix."content_expfiles as cef ON p.id=cef.content_id INNER JOIN ".$db->prefix."expfiles as f ON cef.expfiles_id = f.id where match (p.title,p.model,p.body) against ('" . $this->params['query'] . "') AND p.parent_id=0 order by match (p.title,p.model,p.body) against ('" . $this->params['query'] . "') desc LIMIT 25";
//$res = $db->selectObjectsBySql($sql);
//$res = $db->selectObjectBySql('SELECT * FROM `exponent_product`');
$ar = new expAjaxReply(200, gt('Here\'s the items you wanted'), $res);
$ar->send();
} | Base | 1 |
public function params()
{
$project = $this->getProject();
$values = $this->request->getValues();
if (empty($values['action_name']) || empty($values['project_id']) || empty($values['event_name'])) {
$this->create();
return;
}
$action = $this->actionManager->getAction($values['action_name']);
$action_params = $action->getActionRequiredParameters();
if (empty($action_params)) {
$this->doCreation($project, $values + array('params' => array()));
}
$projects_list = $this->projectUserRoleModel->getActiveProjectsByUser($this->userSession->getId());
unset($projects_list[$project['id']]);
$this->response->html($this->template->render('action_creation/params', array(
'values' => $values,
'action_params' => $action_params,
'columns_list' => $this->columnModel->getList($project['id']),
'users_list' => $this->projectUserRoleModel->getAssignableUsersList($project['id']),
'projects_list' => $projects_list,
'colors_list' => $this->colorModel->getList(),
'categories_list' => $this->categoryModel->getList($project['id']),
'links_list' => $this->linkModel->getList(0, false),
'priorities_list' => $this->projectTaskPriorityModel->getPriorities($project),
'project' => $project,
'available_actions' => $this->actionManager->getAvailableActions(),
'swimlane_list' => $this->swimlaneModel->getList($project['id']),
'events' => $this->actionManager->getCompatibleEvents($values['action_name']),
)));
} | Base | 1 |
public function init() {
global $geo_mashup_options, $pagenow;
// Enable this interface when the option is set and we're on a destination page
$enabled = is_admin() &&
$geo_mashup_options->get( 'overall', 'located_object_name', 'user' ) == 'true' &&
preg_match( '/(user-edit|profile).php/', $pagenow );
$enabled = apply_filters( 'geo_mashup_load_user_editor', $enabled );
// If enabled, register all the interface elements
if ( $enabled ) {
// Form generation
add_action( 'show_user_profile', array( &$this, 'print_form' ) );
add_action( 'edit_user_profile', array( &$this, 'print_form' ) );
// MAYBEDO: add location to registration page?
// Form processing
add_action( 'personal_options_update', array( &$this, 'save_user'));
add_action( 'edit_user_profile_update', array( &$this, 'save_user'));
$this->enqueue_form_client_items();
}
}
| Class | 2 |
}elseif(!in_array($k, $arr) && $k != 'paging'){
//self::error('404');
}else{
self::incFront('default');
}
}
}else{
| Base | 1 |
public function onUpLoadPreSave(&$path, &$name, $src, $elfinder, $volume) {
$opts = $this->opts;
$volOpts = $volume->getOptionsPlugin('AutoResize');
if (is_array($volOpts)) {
$opts = array_merge($this->opts, $volOpts);
}
if (! $opts['enable']) {
return false;
}
$srcImgInfo = @getimagesize($src);
if ($srcImgInfo === false) {
return false;
}
// check target image type
$imgTypes = array(
IMAGETYPE_GIF => IMG_GIF,
IMAGETYPE_JPEG => IMG_JPEG,
IMAGETYPE_PNG => IMG_PNG,
IMAGETYPE_BMP => IMG_WBMP,
IMAGETYPE_WBMP => IMG_WBMP
);
if (! ($opts['targetType'] & @$imgTypes[$srcImgInfo[2]])) {
return false;
}
if ($srcImgInfo[0] > $opts['maxWidth'] || $srcImgInfo[1] > $opts['maxHeight']) {
return $this->resize($src, $srcImgInfo, $opts['maxWidth'], $opts['maxHeight'], $opts['quality'], $opts['preserveExif']);
}
return false;
} | Base | 1 |
public static function sessionWrite() {
$this->session->close();
} | Base | 1 |
public function update_groupdiscounts() {
global $db;
if (empty($this->params['id'])) {
// look for existing discounts for the same group
$existing_id = $db->selectValue('groupdiscounts', 'id', 'group_id='.$this->params['group_id']);
if (!empty($existing_id)) flashAndFlow('error',gt('There is already a discount for that group.'));
}
$gd = new groupdiscounts();
$gd->update($this->params);
expHistory::back();
} | Class | 2 |
unset($m[0][$i], $m[1][$i], $m[2][$i], $m[3][$i], $k, $v, $i);
}
}
return $r;
} | Base | 1 |
public function bind($dn = null, $password = null)
{
/* Fetch current bind credentials. */
if (empty($dn)) {
$dn = $this->_config['binddn'];
}
if (empty($password)) {
$password = $this->_config['bindpw'];
}
/* Connect first, if we haven't so far. This will also bind
* us to the server. */
if (!$this->_link) {
/* Store old credentials so we can revert them later, then
* overwrite config with new bind credentials. */
$olddn = $this->_config['binddn'];
$oldpw = $this->_config['bindpw'];
/* Overwrite bind credentials in config so
* _connect() knows about them. */
$this->_config['binddn'] = $dn;
$this->_config['bindpw'] = $password;
/* Try to connect with provided credentials. */
$msg = $this->_connect();
/* Reset to previous config. */
$this->_config['binddn'] = $olddn;
$this->_config['bindpw'] = $oldpw;
return;
}
/* Do the requested bind as we are asked to bind manually. */
if (empty($dn)) {
/* Anonymous bind. */
$msg = @ldap_bind($this->_link);
} else {
/* Privileged bind. */
$msg = @ldap_bind($this->_link, $dn, $password);
}
if (!$msg) {
throw new Horde_Ldap_Exception('Bind failed: ' . @ldap_error($this->_link),
@ldap_errno($this->_link));
}
} | Class | 2 |
public function remove()
{
$this->checkCSRFParam();
$project = $this->getProject();
$category = $this->getCategory();
if ($this->categoryModel->remove($category['id'])) {
$this->flash->success(t('Category removed successfully.'));
} else {
$this->flash->failure(t('Unable to remove this category.'));
}
$this->response->redirect($this->helper->url->to('CategoryController', 'index', array('project_id' => $project['id'])));
} | Base | 1 |
public static function isHadSub($parent, $menuid =''){
$sql = sprintf("SELECT * FROM `menus` WHERE `parent` = '%s' %s", $parent, $where);
} | Compound | 4 |
public function backup($type='json')
{
global $DB;
global $website;
$out = array();
$DB->query('SELECT * FROM nv_feeds WHERE website = '.protect($website->id), 'object');
$out = $DB->result();
if($type='json')
$out = json_encode($out);
return $out;
}
| Base | 1 |
public function downloadfile() {
if (empty($this->params['fileid'])) {
flash('error', gt('There was an error while trying to download your file. No File Specified.'));
expHistory::back();
}
$fd = new filedownload($this->params['fileid']);
if (empty($this->params['filenum'])) $this->params['filenum'] = 0;
if (empty($fd->expFile['downloadable'][$this->params['filenum']]->id)) {
flash('error', gt('There was an error while trying to download your file. The file you were looking for could not be found.'));
expHistory::back();
}
$fd->downloads++;
$fd->save();
// this will set the id to the id of the actual file..makes the download go right.
$this->params['id'] = $fd->expFile['downloadable'][$this->params['filenum']]->id;
parent::downloadfile();
} | Class | 2 |
public function confirm()
{
$project = $this->getProject();
$tag_id = $this->request->getIntegerParam('tag_id');
$tag = $this->tagModel->getById($tag_id);
$this->response->html($this->template->render('project_tag/remove', array(
'tag' => $tag,
'project' => $project,
)));
} | Base | 1 |
public function delete_version() {
if (empty($this->params['id'])) {
flash('error', gt('The version you are trying to delete could not be found'));
}
// get the version
$version = new help_version($this->params['id']);
if (empty($version->id)) {
flash('error', gt('The version you are trying to delete could not be found'));
}
// if we have errors than lets get outta here!
if (!expQueue::isQueueEmpty('error')) expHistory::back();
// delete the version
$version->delete();
expSession::un_set('help-version');
flash('message', gt('Deleted version').' '.$version->version.' '.gt('and all documents in that version.'));
expHistory::back();
} | Base | 1 |
$dt = date('Y-m-d', strtotime($match));
$sql = par_rep("/'$match'/", "'$dt'", $sql);
}
}
if (substr($sql, 0, 6) == "BEGIN;") {
$array = explode(";", $sql);
foreach ($array as $value) {
if ($value != "") {
$user_agent = explode('/', $_SERVER['HTTP_USER_AGENT']);
if ($user_agent[0] == 'Mozilla') {
$result = $connection->query($value);
}
if (!$result) {
$user_agent = explode('/', $_SERVER['HTTP_USER_AGENT']);
if ($user_agent[0] == 'Mozilla') {
$connection->query("ROLLBACK");
die(db_show_error($sql, _dbExecuteFailed, mysqli_error($connection)));
}
}
}
}
} else {
$user_agent = explode('/', $_SERVER['HTTP_USER_AGENT']);
if ($user_agent[0] == 'Mozilla') {
$result = $connection->query($sql) or die(db_show_error($sql, _dbExecuteFailed, mysqli_error($connection)));
}
}
break;
} | Base | 1 |
public function delete()
{
global $DB;
$node_id_filter = "";
// remove all old entries
if(!empty($this->node_id))
{
if(is_numeric($this->node_id))
$node_id_filter .= ' AND node_id = '.intval($this->node_id);
if(is_numeric($this->node_uid))
$node_id_filter .= ' AND node_uid = '.intval($this->node_uid);
$DB->execute('
DELETE FROM nv_webdictionary
WHERE subtype = '.protect($this->subtype).'
AND node_type = '.protect($this->node_type).'
AND theme = '.protect($this->theme).'
AND extension = '.protect($this->extension).'
AND website = '.protect($this->website).
$node_id_filter
);
}
return $DB->get_affected_rows();
}
| Base | 1 |
static function description() {
return "Manage events and schedules, and optionally publish them.";
}
| Class | 2 |
public function __construct(OrderService $orderService)
{
$this->orderService = $orderService;
} | Class | 2 |
$layout[$position] = array($elem => $initLayout[$position][$elem]) + $layout[$position]; // unshift key-value pair
$changed = true;
}
// remove obsolete widgets
$arrayDiff =
array_diff(array_keys($layoutWidgets), array_keys($initLayoutWidgets));
foreach($arrayDiff as $elem){
if(in_array ($elem, array_keys ($layout[$position]))) {
unset($layout[$position][$elem]);
$changed = true;
} else if($position === 'center' && in_array ($elem, array_keys ($layout['hidden']))) {
unset($layout['hidden'][$elem]);
$changed = true;
}
}
// ensure that widget properties are the same as those in the default layout
foreach($layout[$position] as $name=>$arr){
if (in_array ($name, array_keys ($initLayout[$position])) &&
$initLayout[$position][$name]['title'] !== $arr['title']) {
$layout[$position][$name]['title'] = $initLayout[$position][$name]['title'];
$changed = true;
}
}
if ($position === 'center') {
foreach($layout['hidden'] as $name=>$arr){
if (in_array ($name, array_keys ($initLayout[$position])) &&
$initLayout[$position][$name]['title'] !== $arr['title']) {
$layout['hidden'][$name]['title'] = $initLayout[$position][$name]['title'];
$changed = true;
}
}
}
if($changed){
$this->layout = json_encode($layout);
$this->update(array('layout'));
}
} | Base | 1 |
public function transformAssignedTo($asset)
{
if ($asset->checkedOutToUser()) {
return $asset->assigned ? [
'id' => (int) $asset->assigned->id,
'username' => e($asset->assigned->username),
'name' => e($asset->assigned->getFullNameAttribute()),
'first_name'=> e($asset->assigned->first_name),
'last_name'=> ($asset->assigned->last_name) ? e($asset->assigned->last_name) : null,
'employee_number' => ($asset->assigned->employee_num) ? e($asset->assigned->employee_num) : null,
'type' => 'user'
] : null;
}
return $asset->assigned ? [
'id' => $asset->assigned->id,
'name' => $asset->assigned->display_name,
'type' => $asset->assignedType()
] : null;
} | Base | 1 |
function showByModel() {
global $order, $template, $db;
expHistory::set('viewable', $this->params);
$product = new product();
$model = $product->find("first", 'model="' . $this->params['model'] . '"');
//eDebug($model);
$product_type = new $model->product_type($model->id);
//eDebug($product_type);
$tpl = $product_type->getForm('show');
if (!empty($tpl)) $template = new controllertemplate($this, $tpl);
//eDebug($template);
$this->grabConfig(); // grab the global config
assign_to_template(array(
'config' => $this->config,
'product' => $product_type,
'last_category' => $order->lastcat
));
} | Class | 2 |
public function disable()
{
$this->checkCSRFParam();
$project = $this->getProject();
$swimlane_id = $this->request->getIntegerParam('swimlane_id');
if ($this->swimlaneModel->disable($project['id'], $swimlane_id)) {
$this->flash->success(t('Swimlane updated successfully.'));
} else {
$this->flash->failure(t('Unable to update this swimlane.'));
}
$this->response->redirect($this->helper->url->to('SwimlaneController', 'index', array('project_id' => $project['id'])));
} | Base | 1 |
public function updateTab($id, $array)
{
if (!$id || $id == '') {
$this->setAPIResponse('error', 'id was not set', 422);
return null;
}
if (!$array) {
$this->setAPIResponse('error', 'no data was sent', 422);
return null;
}
$tabInfo = $this->getTabById($id);
if ($tabInfo) {
$array = $this->checkKeys($tabInfo, $array);
} else {
$this->setAPIResponse('error', 'No tab info found', 404);
return false;
}
if (array_key_exists('name', $array)) {
$array['name'] = htmlspecialchars($array['name']);
if ($this->isTabNameTaken($array['name'], $id)) {
$this->setAPIResponse('error', 'Tab name: ' . $array['name'] . ' is already taken', 409);
return false;
}
}
if (array_key_exists('default', $array)) {
if ($array['default']) {
$this->clearTabDefault();
}
}
$response = [
array(
'function' => 'query',
'query' => array(
'UPDATE tabs SET',
$array,
'WHERE id = ?',
$id
)
),
];
$this->setAPIResponse(null, 'Tab info updated');
$this->setLoggerChannel('Tab Management');
$this->logger->debug('Edited Tab Info for [' . $tabInfo['name'] . ']');
return $this->processQueries($response);
} | Base | 1 |
public function remove()
{
$this->checkCSRFParam();
$project = $this->getProject();
$filter = $this->customFilterModel->getById($this->request->getIntegerParam('filter_id'));
$this->checkPermission($project, $filter);
if ($this->customFilterModel->remove($filter['id'])) {
$this->flash->success(t('Custom filter removed successfully.'));
} else {
$this->flash->failure(t('Unable to remove this custom filter.'));
}
$this->response->redirect($this->helper->url->to('CustomFilterController', 'index', array('project_id' => $project['id'])));
} | Base | 1 |
public function confirm()
{
$task = $this->getTask();
$comment = $this->getComment();
$this->response->html($this->template->render('comment/remove', array(
'comment' => $comment,
'task' => $task,
'title' => t('Remove a comment')
)));
} | Base | 1 |
foreach ($evs as $key=>$event) {
if ($condense) {
$eventid = $event->id;
$multiday_event = array_filter($events, create_function('$event', 'global $eventid; return $event->id === $eventid;'));
if (!empty($multiday_event)) {
unset($evs[$key]);
continue;
}
}
$evs[$key]->eventstart += $edate->date;
$evs[$key]->eventend += $edate->date;
$evs[$key]->date_id = $edate->id;
if (!empty($event->expCat)) {
$catcolor = empty($event->expCat[0]->color) ? null : trim($event->expCat[0]->color);
// if (substr($catcolor,0,1)=='#') $catcolor = '" style="color:'.$catcolor.';';
$evs[$key]->color = $catcolor;
}
}
| Base | 1 |
public function delete_version() {
if (empty($this->params['id'])) {
flash('error', gt('The version you are trying to delete could not be found'));
}
// get the version
$version = new help_version($this->params['id']);
if (empty($version->id)) {
flash('error', gt('The version you are trying to delete could not be found'));
}
// if we have errors than lets get outta here!
if (!expQueue::isQueueEmpty('error')) expHistory::back();
// delete the version
$version->delete();
expSession::un_set('help-version');
flash('message', gt('Deleted version').' '.$version->version.' '.gt('and all documents in that version.'));
expHistory::back();
} | Base | 1 |
print_r($single_error);
}
echo '</pre>';
} | Base | 1 |
private function filterPath($path)
{
return preg_replace_callback(
'/(?:[^' . self::$charUnreserved . self::$charSubDelims . ':@\/%]+|%(?![A-Fa-f0-9]{2}))/',
[$this, 'rawurlencodeMatchZero'],
$path
);
} | Base | 1 |
public function enable()
{
$this->checkCSRFParam();
$project = $this->getProject();
$swimlane_id = $this->request->getIntegerParam('swimlane_id');
if ($this->swimlaneModel->enable($project['id'], $swimlane_id)) {
$this->flash->success(t('Swimlane updated successfully.'));
} else {
$this->flash->failure(t('Unable to update this swimlane.'));
}
$this->response->redirect($this->helper->url->to('SwimlaneController', 'index', array('project_id' => $project['id'])));
} | Base | 1 |
public function testCheckLoginPassEntity()
{
$login=checkLoginPassEntity('loginbidon', 'passwordbidon', 1, array('dolibarr'));
print __METHOD__." login=".$login."\n";
$this->assertEquals($login, '');
$login=checkLoginPassEntity('admin', 'passwordbidon', 1, array('dolibarr'));
print __METHOD__." login=".$login."\n";
$this->assertEquals($login, '');
$login=checkLoginPassEntity('admin', 'admin', 1, array('dolibarr')); // Should works because admin/admin exists
print __METHOD__." login=".$login."\n";
$this->assertEquals($login, 'admin');
$login=checkLoginPassEntity('admin', 'admin', 1, array('http','dolibarr')); // Should work because of second authetntication method
print __METHOD__." login=".$login."\n";
$this->assertEquals($login, 'admin');
$login=checkLoginPassEntity('admin', 'admin', 1, array('forceuser'));
print __METHOD__." login=".$login."\n";
$this->assertEquals($login, ''); // Expected '' because should failed because login 'auto' does not exists
} | Base | 1 |
foreach ($elem[2] as $field) {
echo '
<tr class="tr_fields itemCatName_'.$itemCatName.'">
<td valign="top" class="td_title"> <span class="ui-icon ui-icon-carat-1-e" style="float: left; margin: 0 .3em 0 15px; font-size:9px;"> </span><i>'.$field[1].'</i> :</td>
<td>
<div id="id_field_'.$field[0].'" style="display:inline;" class="fields_div"></div><input type="hidden" id="hid_field_'.$field[0].'" class="fields" />
</td>
</tr>';
} | Base | 1 |
public function actionGetItems(){
$model = X2Model::model ($this->modelClass);
if (isset ($model)) {
$tableName = $model->tableName ();
$sql =
'SELECT id, fileName as value
FROM '.$tableName.'
WHERE associationType!="theme" and fileName LIKE :qterm
ORDER BY fileName ASC';
$command = Yii::app()->db->createCommand($sql);
$qterm = $_GET['term'].'%';
$command->bindParam(":qterm", $qterm, PDO::PARAM_STR);
$result = $command->queryAll();
echo CJSON::encode($result);
}
Yii::app()->end();
} | Class | 2 |
public function getFileContent($file, $identifier)
{
$resource = sprintf('hg cat -r %s %s', ProcessExecutor::escape($identifier), ProcessExecutor::escape($file));
$this->process->execute($resource, $content, $this->repoDir);
if (!trim($content)) {
return null;
}
return $content;
} | Class | 2 |
private function getCategory()
{
$category = $this->categoryModel->getById($this->request->getIntegerParam('category_id'));
if (empty($category)) {
throw new PageNotFoundException();
}
return $category;
} | Base | 1 |
function XMLRPCgetUserGroups($groupType=0, $affiliationid=0) {
global $user;
$groups = getUserGroups($groupType, $affiliationid);
// Filter out any groups to which the user does not have access.
$usergroups = array();
foreach($groups as $id => $group){
if($group['ownerid'] == $user['id'] ||
(array_key_exists("editgroupid", $group) &&
array_key_exists($group['editgroupid'], $user["groups"])) ||
(array_key_exists($id, $user["groups"]))){
array_push($usergroups, $group);
}
}
return array(
"status" => "success",
"groups" => $usergroups);
} | Class | 2 |
public function theme_switch() {
if (!expUtil::isReallyWritable(BASE.'framework/conf/config.php')) { // we can't write to the config.php file
flash('error',gt('The file /framework/conf/config.php is NOT Writeable. You will be unable to change the theme.'));
}
expSettings::change('DISPLAY_THEME_REAL', $this->params['theme']);
expSession::set('display_theme',$this->params['theme']);
$sv = isset($this->params['sv'])?$this->params['sv']:'';
if (strtolower($sv)=='default') {
$sv = '';
}
expSettings::change('THEME_STYLE_REAL',$sv);
expSession::set('theme_style',$sv);
expDatabase::install_dbtables(); // update tables to include any custom definitions in the new theme
// $message = (MINIFY != 1) ? "Exponent is now minifying Javascript and CSS" : "Exponent is no longer minifying Javascript and CSS" ;
// flash('message',$message);
$message = gt("You have selected the")." '".$this->params['theme']."' ".gt("theme");
if ($sv != '') {
$message .= ' '.gt('with').' '.$this->params['sv'].' '.gt('style variation');
}
flash('message',$message);
// expSession::un_set('framework');
expSession::set('force_less_compile', 1);
// expTheme::removeSmartyCache();
expSession::clearAllUsersSessionCache();
expHistory::returnTo('manageable');
} | Base | 1 |
public function up(RuleGroup $ruleGroup)
{
$order = (int)$ruleGroup->order;
if ($order > 1) {
$newOrder = $order - 1;
$this->repository->setOrder($ruleGroup, $newOrder);
}
return redirect(route('rules.index'));
} | Compound | 4 |
$bool = self::evaluateTypedCondition($array, $expression);
if (!$bool) {
$hit->parentNode->removeChild($hit);
} else {
$hit->removeAttribute('n-if');
}
}
return $doc->saveHTML();
} | Class | 2 |
function manage_vendors () {
expHistory::set('viewable', $this->params);
$vendor = new vendor();
$vendors = $vendor->find('all');
assign_to_template(array(
'vendors'=>$vendors
));
} | Class | 2 |
public function confirm()
{
$project = $this->getProject();
$filter = $this->customFilterModel->getById($this->request->getIntegerParam('filter_id'));
$this->response->html($this->helper->layout->project('custom_filter/remove', array(
'project' => $project,
'filter' => $filter,
'title' => t('Remove a custom filter')
)));
} | Base | 1 |
public function testAuth()
{
if (! defined('PMA_TEST_HEADERS')) {
$this->markTestSkipped(
'Cannot redefine constant/function - missing runkit extension'
);
}
// case 1
$GLOBALS['cfg']['Server']['SignonURL'] = '';
ob_start();
$this->object->auth();
$result = ob_get_clean();
$this->assertContains(
'You must set SignonURL!',
$result
);
// case 2
$GLOBALS['cfg']['Server']['SignonURL'] = 'http://phpmyadmin.net/SignonURL';
$_REQUEST['old_usr'] = 'oldUser';
$GLOBALS['cfg']['Server']['LogoutURL'] = 'http://phpmyadmin.net/logoutURL';
$this->object->auth();
$this->assertContains(
'Location: http://phpmyadmin.net/logoutURL?PHPSESSID=',
$GLOBALS['header'][0]
);
// case 3
$GLOBALS['header'] = array();
$GLOBALS['cfg']['Server']['SignonURL'] = 'http://phpmyadmin.net/SignonURL';
$_REQUEST['old_usr'] = '';
$GLOBALS['cfg']['Server']['LogoutURL'] = '';
$this->object->auth();
$this->assertContains(
'Location: http://phpmyadmin.net/SignonURL?PHPSESSID=',
$GLOBALS['header'][0]
);
} | Class | 2 |
public static function parseAndTrimImport($str, $isHTML = false) { //�Death from above�? �
//echo "1<br>"; eDebug($str);
// global $db;
$str = str_replace("�", "’", $str);
$str = str_replace("�", "‘", $str);
$str = str_replace("�", "®", $str);
$str = str_replace("�", "-", $str);
$str = str_replace("�", "—", $str);
$str = str_replace("�", "”", $str);
$str = str_replace("�", "“", $str);
$str = str_replace("\r\n", " ", $str);
$str = str_replace("\,", ",", $str);
$str = str_replace('""', '"', $str); //do this no matter what...in case someone added a quote in a non HTML field
if (!$isHTML) {
//if HTML, then leave the single quotes alone, otheriwse replace w/ special Char
$str = str_replace('"', """, $str);
}
$str = str_replace("�", "¼", $str);
$str = str_replace("�", "½", $str);
$str = str_replace("�", "¾", $str);
//$str = htmlspecialchars($str);
//$str = utf8_encode($str);
// if (DB_ENGINE=='mysqli') {
// $str = @mysqli_real_escape_string($db->connection,trim(str_replace("�", "™", $str)));
// } elseif(DB_ENGINE=='mysql') {
// $str = @mysql_real_escape_string(trim(str_replace("�", "™", $str)),$db->connection);
// } else {
// $str = trim(str_replace("�", "™", $str));
// }
$str = @expString::escape(trim(str_replace("�", "™", $str)));
//echo "2<br>"; eDebug($str,die);
return $str;
} | Base | 1 |
public function __construct( $title, $namespace ) {
$this->mTitle = $title;
$this->mNamespace = $namespace;
} | Class | 2 |
public function execute(&$params){
$options = &$this->config['options'];
$notif = new Notification;
$notif->user = $this->parseOption('user', $params);
$notif->createdBy = 'API';
$notif->createDate = time();
// file_put_contents('triggerLog.txt',"\n".$notif->user,FILE_APPEND);
// if($this->parseOption('type',$params) == 'auto') {
// if(!isset($params['model']))
// return false;
// $notif->modelType = get_class($params['model']);
// $notif->modelId = $params['model']->id;
// $notif->type = $this->getNotifType();
// } else {
$notif->type = 'custom';
$notif->text = $this->parseOption('text', $params);
// }
if ($notif->save()) {
return array (true, "");
} else {
return array(false, array_shift($notif->getErrors()));
}
} | Class | 2 |
public function confirm()
{
$project = $this->getProject();
$category = $this->getCategory();
$this->response->html($this->helper->layout->project('category/remove', array(
'project' => $project,
'category' => $category,
)));
} | Base | 1 |
function edit_section() {
global $db, $user;
$parent = new section($this->params['parent']);
if (empty($parent->id)) $parent->id = 0;
assign_to_template(array(
'haveStandalone' => ($db->countObjects('section', 'parent=-1') && $parent->id >= 0),
'parent' => $parent,
'isAdministrator' => $user->isAdmin(),
));
}
| Base | 1 |
: htmlspecialchars($host['User'])) . '</label></td>' . "\n"
. '<td>' . htmlspecialchars($host['Host']) . '</td>' . "\n";
$html_output .= '<td>';
$password_column = 'Password';
$check_plugin_query = "SELECT * FROM `mysql`.`user` WHERE "
. "`User` = '" . $host['User'] . "' AND `Host` = '"
. $host['Host'] . "'";
$res = $GLOBALS['dbi']->fetchSingleRow($check_plugin_query);
if ((isset($res['authentication_string'])
&& ! empty($res['authentication_string']))
|| (isset($res['Password'])
&& ! empty($res['Password']))
) {
$host[$password_column] = 'Y';
} else {
$host[$password_column] = 'N';
}
switch ($host[$password_column]) {
case 'Y':
$html_output .= __('Yes');
break;
case 'N':
$html_output .= '<span style="color: #FF0000">' . __('No')
. '</span>';
break;
// this happens if this is a definition not coming from mysql.user
default:
$html_output .= '--'; // in future version, replace by "not present"
break;
} // end switch
$html_output .= '</td>' . "\n";
$html_output .= '<td><code>' . "\n"
. '' . implode(',' . "\n" . ' ', $host['privs']) . "\n"
. '</code></td>' . "\n";
if ($cfgRelation['menuswork']) {
$html_output .= '<td class="usrGroup">' . "\n"
. (isset($group_assignment[$host['User']])
? $group_assignment[$host['User']]
: ''
)
. '</td>' . "\n";
} | Base | 1 |
private function _lastrevisionbefore( $option ) {
$this->addTable( 'revision_actor_temp', 'rev' );
$this->addSelect( [ 'rev.revactor_rev', 'rev.revactor_timestamp' ] );
// tell the query optimizer not to look at rows that the following subquery will filter out anyway
$this->addWhere(
[
$this->tableNames['page'] . '.page_id = rev.revactor_page',
'rev.revactor_timestamp < ' . $this->convertTimestamp( $option )
]
);
$this->addWhere(
[
$this->tableNames['page'] . '.page_id = rev.revactor_page',
'rev.revactor_timestamp = (SELECT MAX(rev_aux_bef.revactor_timestamp) FROM ' . $this->tableNames['revision_actor_temp'] . ' AS rev_aux_bef WHERE rev_aux_bef.revactor_page=rev.revactor_page AND rev_aux_bef.revactor_timestamp < ' . $this->convertTimestamp( $option ) . ')'
]
);
} | Class | 2 |
static function description() {
return "Manage events and schedules, and optionally publish them.";
}
| Base | 1 |
protected function redirectToGroup(Thread $thread, $group_id)
{
if ($thread->state != Thread::STATE_CHATTING) {
// We can redirect only threads which are in proggress now.
return false;
}
// Redirect the thread
$thread->state = Thread::STATE_WAITING;
$thread->nextAgent = 0;
$thread->groupId = $group_id;
$thread->agentId = 0;
$thread->agentName = '';
$thread->save();
// Send notification message
$thread->postMessage(
Thread::KIND_EVENTS,
getlocal(
'Operator {0} redirected you to another operator. Please wait a while.',
array(get_operator_name($this->getOperator())),
$thread->locale,
true
)
);
return true;
} | Base | 1 |
public static function IsTransactionValid($id, $bRemoveTransaction = true)
{
// Constraint the transaction file within APPROOT.'data/transactions'
$sTransactionDir = realpath(APPROOT.'data/transactions');
$sFilepath = utils::RealPath($sTransactionDir.'/'.$id, $sTransactionDir);
if (($sFilepath === false) || (strlen($sTransactionDir) == strlen($sFilepath)))
{
return false;
}
clearstatcache(true, $sFilepath);
$bResult = file_exists($sFilepath);
if ($bResult)
{
if ($bRemoveTransaction)
{
$bResult = @unlink($sFilepath);
if (!$bResult)
{
self::Error('IsTransactionValid: FAILED to remove transaction '.$id);
}
else
{
self::Info('IsTransactionValid: OK. Removed transaction: '.$id);
}
}
}
else
{
self::Info("IsTransactionValid: Transaction '$id' not found. Pending transactions for this user:\n".implode("\n", self::GetPendingTransactions()));
}
return $bResult;
} | Compound | 4 |
public function disable()
{
$this->checkCSRFParam();
$project = $this->getProject();
$swimlane_id = $this->request->getIntegerParam('swimlane_id');
if ($this->swimlaneModel->disable($project['id'], $swimlane_id)) {
$this->flash->success(t('Swimlane updated successfully.'));
} else {
$this->flash->failure(t('Unable to update this swimlane.'));
}
$this->response->redirect($this->helper->url->to('SwimlaneController', 'index', array('project_id' => $project['id'])));
} | Base | 1 |
$navs[$i]->link = expCore::makeLink(array('section' => $navs[$i]->id), '', $navs[$i]->sef_name);
if (!$view) {
// unset($navs[$i]); //FIXME this breaks jstree if we remove a parent and not the child
$attr = new stdClass();
$attr->class = 'hidden'; // bs3 class to hide elements
$navs[$i]->li_attr = $attr;
}
}
| Base | 1 |
public static function get_param($key = NULL) {
$info = [
'stype' => self::$search_type,
'stext' => self::$search_text,
'method' => self::$search_method,
'datelimit' => self::$search_date_limit,
'fields' => self::$search_fields,
'sort' => self::$search_sort,
'chars' => self::$search_chars,
'order' => self::$search_order,
'forum_id' => self::$forum_id,
'memory_limit' => self::$memory_limit,
'composevars' => self::$composevars,
'rowstart' => self::$rowstart,
'search_param' => self::$search_param,
];
return $key === NULL ? $info : (isset($info[$key]) ? $info[$key] : NULL);
} | Base | 1 |
public function getSimilar($id){
$url = "http://api.themoviedb.org/3/movie/{$id}/similar?api_key=".$this->apikey;
$similar = $this->curl($url);
return $similar;
}
| Base | 1 |
function draw_vdef_preview($vdef_id) {
?>
<tr class='even'>
<td style='padding:4px'>
<pre>vdef=<?php print get_vdef($vdef_id, true);?></pre>
</td>
</tr>
<?php
} | Base | 1 |
function delete() {
global $db;
if (empty($this->params['id'])) return false;
$product_type = $db->selectValue('product', 'product_type', 'id=' . $this->params['id']);
$product = new $product_type($this->params['id'], true, false);
//eDebug($product_type);
//eDebug($product, true);
//if (!empty($product->product_type_id)) {
//$db->delete($product_type, 'id='.$product->product_id);
//}
$db->delete('option', 'product_id=' . $product->id . " AND optiongroup_id IN (SELECT id from " . $db->prefix . "optiongroup WHERE product_id=" . $product->id . ")");
$db->delete('optiongroup', 'product_id=' . $product->id);
//die();
$db->delete('product_storeCategories', 'product_id=' . $product->id . ' AND product_type="' . $product_type . '"');
if ($product->product_type == "product") {
if ($product->hasChildren()) {
$this->deleteChildren();
}
}
$product->delete();
flash('message', gt('Product deleted successfully.'));
expHistory::back();
} | Base | 1 |
$rst[$key] = self::parseAndTrim($st, $unescape);
}
return $rst;
}
$str = str_replace("<br>"," ",$str);
$str = str_replace("</br>"," ",$str);
$str = str_replace("<br/>"," ",$str);
$str = str_replace("<br />"," ",$str);
$str = str_replace("\r\n"," ",$str);
$str = str_replace('"',""",$str);
$str = str_replace("'","'",$str);
$str = str_replace("’","’",$str);
$str = str_replace("‘","‘",$str);
$str = str_replace("®","®",$str);
$str = str_replace("–","-", $str);
$str = str_replace("—","—", $str);
$str = str_replace("”","”", $str);
$str = str_replace("“","“", $str);
$str = str_replace("¼","¼",$str);
$str = str_replace("½","½",$str);
$str = str_replace("¾","¾",$str);
$str = str_replace("™","™", $str);
$str = trim($str);
if ($unescape) {
$str = stripcslashes($str);
} else {
$str = addslashes($str);
}
return $str;
} | Class | 2 |
public function update() {
global $user;
if (expSession::get('customer-signup')) expSession::set('customer-signup', false);
if (isset($this->params['address_country_id'])) {
$this->params['country'] = $this->params['address_country_id'];
unset($this->params['address_country_id']);
}
if (isset($this->params['address_region_id'])) {
$this->params['state'] = $this->params['address_region_id'];
unset($this->params['address_region_id']);
}
if ($user->isLoggedIn()) {
// check to see how many other addresses this user has already.
$count = $this->address->find('count', 'user_id='.$user->id);
// if this is first address save for this user we'll make this the default
if ($count == 0)
{
$this->params['is_default'] = 1;
$this->params['is_billing'] = 1;
$this->params['is_shipping'] = 1;
}
// associate this address with the current user.
$this->params['user_id'] = $user->id;
// save the object
$this->address->update($this->params);
}
else { //if (ecomconfig::getConfig('allow_anonymous_checkout')){
//user is not logged in, but allow anonymous checkout is enabled so we'll check
//a few things that we don't check in the parent 'stuff and create a user account.
$this->params['is_default'] = 1;
$this->params['is_billing'] = 1;
$this->params['is_shipping'] = 1;
$this->address->update($this->params);
}
expHistory::back();
} | Class | 2 |
function edit_section() {
global $db, $user;
$parent = new section($this->params['parent']);
if (empty($parent->id)) $parent->id = 0;
assign_to_template(array(
'haveStandalone' => ($db->countObjects('section', 'parent=-1') && $parent->id >= 0),
'parent' => $parent,
'isAdministrator' => $user->isAdmin(),
));
}
| Base | 1 |
protected function getComment()
{
$comment = $this->commentModel->getById($this->request->getIntegerParam('comment_id'));
if (empty($comment)) {
throw new PageNotFoundException();
}
if (! $this->userSession->isAdmin() && $comment['user_id'] != $this->userSession->getId()) {
throw new AccessForbiddenException();
}
return $comment;
} | Base | 1 |
public function show_screen_options() {
global $wp_meta_boxes;
if ( is_bool( $this->_show_screen_options ) )
return $this->_show_screen_options;
$columns = get_column_headers( $this );
$show_screen = ! empty( $wp_meta_boxes[ $this->id ] ) || $columns || $this->get_option( 'per_page' );
switch ( $this->base ) {
case 'widgets':
$this->_screen_settings = '<p><a id="access-on" href="widgets.php?widgets-access=on">' . __('Enable accessibility mode') . '</a><a id="access-off" href="widgets.php?widgets-access=off">' . __('Disable accessibility mode') . "</a></p>\n";
break;
case 'post' :
$expand = '<fieldset class="editor-expand hidden"><legend>' . __( 'Additional settings' ) . '</legend><label for="editor-expand-toggle">';
$expand .= '<input type="checkbox" id="editor-expand-toggle"' . checked( get_user_setting( 'editor_expand', 'on' ), 'on', false ) . ' />';
$expand .= __( 'Enable full-height editor and distraction-free functionality.' ) . '</label></fieldset>';
$this->_screen_settings = $expand;
break;
default:
$this->_screen_settings = '';
break;
}
/**
* Filters the screen settings text displayed in the Screen Options tab.
*
* This filter is currently only used on the Widgets screen to enable
* accessibility mode.
*
* @since 3.0.0
*
* @param string $screen_settings Screen settings.
* @param WP_Screen $this WP_Screen object.
*/
$this->_screen_settings = apply_filters( 'screen_settings', $this->_screen_settings, $this );
if ( $this->_screen_settings || $this->_options )
$show_screen = true;
/**
* Filters whether to show the Screen Options tab.
*
* @since 3.2.0
*
* @param bool $show_screen Whether to show Screen Options tab.
* Default true.
* @param WP_Screen $this Current WP_Screen instance.
*/
$this->_show_screen_options = apply_filters( 'screen_options_show_screen', $show_screen, $this );
return $this->_show_screen_options;
} | Compound | 4 |
$subgroup->remove(true);
}
}
Analog::log(
'Cascading remove ' . $this->group_name .
'. Members and managers will be detached.',
Analog::INFO
);
//delete members
$delete = $zdb->delete(self::GROUPSUSERS_TABLE);
$delete->where(
self::PK . ' = ' . $this->id
);
$zdb->execute($delete);
//delete managers
$delete = $zdb->delete(self::GROUPSMANAGERS_TABLE);
$delete->where(
self::PK . ' = ' . $this->id
);
$zdb->execute($delete);
}
//delete group itself
$delete = $zdb->delete(self::TABLE);
$delete->where(
self::PK . ' = ' . $this->id
);
$zdb->execute($delete);
//commit all changes
if ($transaction) {
$zdb->connection->commit();
}
return true;
} catch (Throwable $e) {
if ($transaction) {
$zdb->connection->rollBack();
}
if ($e->getCode() == 23000) {
Analog::log(
str_replace(
'%group',
$this->group_name,
'Group "%group" still have members!'
),
Analog::WARNING
);
$this->isempty = false;
} else {
Analog::log(
'Unable to delete group ' . $this->group_name .
' (' . $this->id . ') |' . $e->getMessage(),
Analog::ERROR
);
throw $e;
}
return false;
}
} | Base | 1 |
$this->doDelete( $type, $dump );
}
}
$pager = new DataDumpPager( $this->getContext(), $this->getPageTitle() );
$out->addModuleStyles( 'mediawiki.special' );
$pager->getForm();
$out->addParserOutputContent( $pager->getFullOutput() );
} | Compound | 4 |
function manage() {
expHistory::set('viewable', $this->params);
// $category = new storeCategory();
// $categories = $category->getFullTree();
//
// // foreach($categories as $i=>$val){
// // if (!empty($this->values) && in_array($val->id,$this->values)) {
// // $this->tags[$i]->value = true;
// // } else {
// // $this->tags[$i]->value = false;
// // }
// // $this->tags[$i]->draggable = $this->draggable;
// // $this->tags[$i]->checkable = $this->checkable;
// // }
//
// $obj = json_encode($categories);
} | Base | 1 |
$mime = mime_content_type($path);
} elseif ($type === 'getimagesize') {
if ($img = @getimagesize($path)) {
$mime = $img['mime'];
}
}
if ($mime) {
$mime = explode(';', $mime);
$mime = trim($mime[0]);
if (in_array($mime, array('application/x-empty', 'inode/x-empty'))) {
// finfo return this mime for empty files
$mime = 'text/plain';
} elseif ($mime == 'application/x-zip') {
// http://elrte.org/redmine/issues/163
$mime = 'application/zip';
}
}
$ext = $mime? $volume->getExtentionByMime($mime) : '';
return $ext? ('.' . $ext) : '';
} | Base | 1 |
public static function find_by_reference($reference, $website_id=null)
{
global $DB;
global $website;
if(empty($website_id))
$website_id = $website->id;
$order_id = $DB->query_single(
'id',
'nv_orders',
'reference = '.protect($reference).' AND website = "'.$website_id.'"'
);
return $order_id;
}
| Base | 1 |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.