public function runJobs() { $cb = function ($msg) { $obj = unserialize($msg->body); echo date('Y-m-d H:i:s') . ': Running ' . get_class($obj) . '...'; try { $msg->delivery_info['channel']->basic_ack($msg->delivery_info['delivery_tag']); if ($obj instanceof Job) { $obj->run(); } } catch (\Exception $e) { Analog::log($e); echo 'Exception caught: ' . $e->getMessage() . "\n"; $fjq = FailedJobQueue::getInstance(); $fjq->add($obj); } echo "done\n"; }; $this->channel->basic_qos(null, 1, null); $this->channel->basic_consume($this->queue_name, '', false, false, false, false, $cb); try { while (count($this->channel->callbacks)) { $this->channel->wait(null, false, 240); } } catch (AMQPTimeoutException $e) { echo 'timing out. finished running jobs'; } }
/** * @param string $data */ public function getCartData($data) { $cart = substr($data, 0, strpos($data, ',')); $cust = substr($data, strpos($data, ',') + 1); Analog::log("Cart & customer variables: {$data}"); $otherCarts = $this->processFindCarts($cart, $cust); return $otherCarts; }
public function testIssue150() { $sql = "SELECT cast((ra/cos(cast(dec*30 as int)/30.0))*30 as int)/30.0 as raCosDec,\ncast(dec*30 as int)/30.0 as dec,\ncount(*) as pop\nFROM Galaxy as G,\nfHTM_Cover('CONVEX J2000 6 175 -5 175 5 185 5 185 -5') as T\nWHERE htmID between T.HTMIDstart* power(2,28)and T. HTMIDend*power(2,28)\nand ra between 175 and 185\nand dec between -5 and 5\nand u-g > 1\nand r < 21.5\nGROUP BY cast((ra/cos(cast(dec*30 as int)/30.0))*30 as int)/30.0,\ncast(dec*30 as int)/30.0 "; $parser = new PHPSQLParser($sql, false); $p = $parser->parsed; Analog::log(print_r($p, true)); $calc = $p['SELECT'][0]['sub_tree'][0]['sub_tree'][0]['sub_tree'][0]['sub_tree'][2]['sub_tree'][0]['sub_tree'][0]['sub_tree'][0]['sub_tree'][0]['expr_type']; $this->assertEquals('colref', $calc, 'wrong reserved keyword'); }
public function testIssue117() { // TODO: not solved, ORDER BY has been lost $sql = "(((SELECT x FROM table)) ORDER BY x)"; $parser = new PHPSQLParser($sql, true); $p = $parser->parsed; Analog::log(print_r($p, true)); $expected = getExpectedValue(dirname(__FILE__), 'issue117.serialized'); $this->assertEquals($expected, $p, 'parentheses on the first position of statement'); }
public function testIssue44() { $parser = new PHPSQLParser(); $sql = "SELECT m.id, m.title, m.module, m.position, m.content, m.showtitle, m.params, mm.menuid\n FROM kj9un_modules AS m\n LEFT JOIN kj9un_modules_menu AS mm ON mm.moduleid = m.id\n LEFT JOIN kj9un_extensions AS e ON e.element = m.module AND e.client_id = m.client_id\n WHERE m.published = 1 AND e.enabled = 1 AND (m.publish_up = '0000-00-00 00:00:00' OR m.publish_up <= '2012-04-21 09:44:01') AND (m.publish_down = '0000-00-00 00:00:00' OR m.publish_down >= '2012-04-21 09:44:01') AND m.access IN (1,1) AND m.client_id = 0 AND (mm.menuid = 170 OR mm.menuid <= 0) AND m.language IN ('en-GB','*')\n ORDER BY m.position, m.ordering"; $parser->parse($sql, true); $p = $parser->parsed; Analog::log(serialize($p)); $expected = getExpectedValue(dirname(__FILE__), 'issue44.serialized'); $this->assertEquals($expected, $p, 'issue 44 position problem'); }
public function testUnion1() { $parser = new PHPSQLParser(); $sql = 'SELECT colA From test a union SELECT colB from test as b'; $p = $parser->parse($sql, true); Analog::log(serialize($p)); $expected = getExpectedValue(dirname(__FILE__), 'union1.serialized'); $this->assertEquals($expected, $p, 'simple union'); }
/** * @param string $data */ public function getProductData($data) { $category = (int) substr($data, 0, strpos($data, ',')); if ($category != 0) { $products = $this->getProducts($category); } else { $product = substr($data, strpos($data, ',') + 1); $products = $this->getProducts($product); } Analog::log("Product variables: {$data}"); return $products; }
/** * @param string $data */ public function getCombinationData($data) { $product = substr($data, 0, strpos($data, ',')); $combinations = []; $vars = explode(',', $data); Analog::log("Product variables: {$data}"); $choices = array_slice($vars, 1); $id_product_attribute = $this->getAttribute($product, $choices); Analog::log("Product combination: {$id_product_attribute}"); $combo_groups = $this->getCombination($product, $id_product_attribute); if (!empty($combo_groups) && is_array($combo_groups) && $combo_groups) { foreach ($combo_groups as $k => $row) { $combinations = $this->buildAttributes($combinations, $id_product_attribute, $row); } } return $combinations; }
public function runJobs() { $cb = function ($msg) { $obj = unserialize($msg->body); try { echo date('Y-m-d H:i:s') . ': Running ' . get_class($obj) . '...'; if ($obj instanceof Job) { $obj->run(); } $msg->delivery_info['channel']->basic_ack($msg->delivery_info['delivery_tag']); } catch (\Exception $e) { Analog::log($e); echo 'Exception caught: ' . $e->getMessage() . "\n"; exit; } echo "done\n"; }; $this->channel->basic_qos(null, 1, null); $this->channel->basic_consume($this->queue_name, '', false, false, false, false, $cb); while (count($this->channel->callbacks)) { $this->channel->wait(); } }
/** * Set managers * * @param Adherent[] $members Managers list * * @return boolean */ public function setManagers($members) { global $zdb; try { $zdb->connection->beginTransaction(); //first, remove current groups managers $delete = $zdb->delete(self::GROUPSMANAGERS_TABLE); $delete->where(self::PK . ' = ' . $this->_id); $zdb->execute($delete); Analog::log('Group managers has been removed for `' . $this->_group_name . '`, we can now store new ones.', Analog::INFO); $insert = $zdb->insert(self::GROUPSMANAGERS_TABLE); $insert->values(array(self::PK => ':group', Adherent::PK => ':adh')); $stmt = $zdb->sql->prepareStatementForSqlObject($insert); if (is_array($members)) { foreach ($members as $m) { $result = $stmt->execute(array(Group::PK => $this->_id, Adherent::PK => $m->id)); if ($result) { Analog::log('Manager `' . $m->sname . '` attached to group `' . $this->_group_name . '`.', Analog::DEBUG); } else { Analog::log('An error occured trying to attach manager `' . $m->sname . '` to group `' . $this->_group_name . '` (' . $this->_id . ').', Analog::ERROR); throw new \Exception('Unable to attach `' . $m->sname . '` ' . 'to ' . $this->_group_name . '(' . $this->_id . ')'); } } } //commit all changes $zdb->connection->commit(); Analog::log('Groups managers updated successfully.', Analog::INFO); return true; } catch (\Exception $e) { $zdb->connection->rollBack(); $messages = array(); do { $messages[] = $e->getMessage(); } while ($e = $e->getPrevious()); Analog::log('Unable to attach managers to group `' . $this->_group_name . '` (' . $this->_id . ')|' . implode("\n", $messages), Analog::ERROR); return false; } }
/** * Get file mime type * * @param string $file File * * @return string */ public static function getMimeType($file) { $mime = null; $class = get_class($this); if (function_exists('finfo_open')) { Analog::log('[' . $class . '] Function File Info exist ', Analog::DEBUG); $finfo = finfo_open(FILEINFO_MIME_TYPE); $mime = finfo_file($finfo, $file); finfo_close($finfo); } else { if (function_exists('mime_content_type')) { Analog::log('[' . $class . '] Function mime_content_type exist ', Analog::DEBUG); $mime = mime_content_type($file); } else { Analog::log('[' . $class . '] Search from extension ', Analog::DEBUG); $ext = strtolower(array_pop(explode('.', $file))); Analog::log('[' . $class . '] Extension : ' . $ext, Analog::DEBUG); if (array_key_exists($ext, self::$mime_types)) { $mime = self::$mime_types[$ext]; } else { $mime = 'application/octet-stream'; } } } Analog::log('[' . $class . '] Found mimetype : ' . $mime . ' for file ' . $file, Analog::INFO); return $mime; }
die; } // check for ajax mode $ajax = isset($_POST['ajax']) && $_POST['ajax'] == 'true' ? true : false; $group = new Galette\Entity\Group((int) $id); if (!isset($_POST['reorder'])) { $groups = new Galette\Repository\Groups(); $tpl->assign('ajax', $ajax); $tpl->assign('group', $group); $tpl->assign('groups', $groups->getList()); if ($ajax) { $tpl->assign('mode', 'ajax'); $tpl->display('group.tpl'); } else { $tpl->assign('require_tabs', true); $content = $tpl->fetch('group.tpl'); $tpl->assign('content', $content); $tpl->display('page.tpl'); } } else { //asking to reorder if (isset($_POST['to'])) { $group->setParentGroup((int) $_POST['to']); $group->store(); echo json_encode(array('success' => 'true')); } else { Analog::log('Trying to reorder without target specified', Analog::INFO); echo json_encode(array('success' => false)); die; } }
/** * Resize the image if it exceed max allowed sizes * * @param string $source the source image * @param string $dest the destination image. * @param string $format the format to use * * @return void */ public function resize($source, $dest, $format) { $gdinfo = gd_info(); $fmts = $this->conf->getFormats(); $fmt = $fmts[$format]; $h = $fmt['height']; $w = $fmt['width']; switch ($this->img_type) { case IMAGETYPE_JPEG: if (!$gdinfo['JPEG Support']) { Analog::log('[' . $this->get_class($this) . '] GD has no JPEG Support - ' . 'pictures could not be resized!', Analog::ERROR); return false; } break; case IMAGETYPE_PNG: if (!$gdinfo['PNG Support']) { Analog::log('[' . $this->get_class($this) . '] GD has no PNG Support - ' . 'pictures could not be resized!', Analog::ERROR); return false; } break; case IMAGETYPE_GIF: if (!$gdinfo['GIF Create Support']) { Analog::log('[' . $this->get_class($this) . '] GD has no GIF Support - ' . 'pictures could not be resized!', Analog::ERROR); return false; } break; default: Analog::error('Current image type cannot be resized'); return false; } list($cur_width, $cur_height, $cur_type, $curattr) = getimagesize($source); $ratio = $cur_width / $cur_height; // calculate image size according to ratio if ($cur_width > $cur_height) { $h = $w / $ratio; } else { $w = $h * $ratio; } $thumb = imagecreatetruecolor($w, $h); $image = $this->_getImageAsResource($source); switch ($this->img_type) { case IMAGETYPE_JPEG: imagecopyresampled($thumb, $image, 0, 0, 0, 0, $w, $h, $cur_width, $cur_height); imagejpeg($thumb, $dest); break; case IMAGETYPE_PNG: // Turn off alpha blending and set alpha flag. That prevent alpha // transparency to be saved as an arbitrary color (black in my tests) imagealphablending($thumb, false); imagealphablending($image, false); imagesavealpha($thumb, true); imagesavealpha($image, true); imagecopyresampled($thumb, $image, 0, 0, 0, 0, $w, $h, $cur_width, $cur_height); imagepng($thumb, $dest, 9); break; case IMAGETYPE_GIF: imagecopyresampled($thumb, $image, 0, 0, 0, 0, $w, $h, $cur_width, $cur_height); imagegif($thumb, $dest); break; case IMAGETYPE_TIFF_II: case IMAGETYPE_TIFF_MM: /** Gd cannot resize TIFF images. */ throw new \RuntimeException(_('TIFF images cannot be resized using Gd library!')); break; } }
/** * Get field values * * @return array */ public function getValues() { if ($this->fixed_values) { return implode("\n", $this->values); } else { Analog::log('Field do not have fixed values, cannot retrieve values.', Analog::INFO); return false; } }
/** * Set default fields categories at install time * * @param Db $zdb Database instance * * @return boolean|Exception */ public function installInit($zdb) { try { //first, we drop all values $delete = $zdb->delete(self::TABLE); $zdb->execute($delete); $insert = $zdb->insert(self::TABLE); $insert->values(array(self::PK => ':id', 'table_name' => ':table_name', 'category' => ':category', 'position' => ':position')); $stmt = $zdb->sql->prepareStatementForSqlObject($insert); foreach ($this->_defaults as $d) { $stmt->execute(array(self::PK => $d['id'], 'table_name' => $d['table_name'], 'category' => $d['category'], 'position' => $d['position'])); } Analog::log('Default fields configurations were successfully stored.', Analog::INFO); return true; } catch (\Exception $e) { Analog::log('Unable to initialize default fields configuration.' . $e->getMessage(), Analog::WARNING); return $e; } }
/** * Global setter method * * @param string $name name of the property we want to assign a value to * @param object $value a relevant value for the property * * @return void */ public function __set($name, $value) { Analog::log('[' . get_class($this) . '|Pagination] Setting property `' . $name . '`', Analog::DEBUG); $rname = '_' . $name; switch ($name) { case 'ordered': if ($value == self::ORDER_ASC || $value == self::ORDER_DESC) { $this->{$rname} = $value; } else { Analog::log('[' . get_class($this) . '|Pagination] Possibles values for field `' . $name . '` are: `' . self::ORDER_ASC . '` or `' . self::ORDER_DESC . '` - `' . $value . '` given', Analog::WARNING); } break; case 'orderby': if ($this->{$rname} == $value) { $this->invertorder(); } else { $this->{$rname} = $value; $this->setDirection(self::ORDER_ASC); } break; case 'current_page': case 'counter': case 'pages': if (is_int($value) && $value > 0) { $this->{$rname} = $value; } else { Analog::log('[' . get_class($this) . '|Pagination] Value for field `' . $name . '` should be a positive integer - (' . gettype($value) . ')' . $value . ' given', Analog::WARNING); } break; case 'show': if ($value == 'all' || preg_match('/[[:digit:]]/', $value) && $value >= 0) { $this->{$rname} = (int) $value; } else { Analog::log('[' . get_class($this) . '|Pagination] Value for `' . $name . '` should be a positive integer or \'all\' - (' . gettype($value) . ')' . $value . ' given', Analog::WARNING); } break; default: Analog::log('[' . get_class($this) . '|Pagination] Unable to set proprety `' . $name . '`', Analog::WARNING); break; } }
/** * Get a translation stored in the database * * @param string $text_orig Text to translate * @param string $text_locale The locale * * @return translated string */ function getDynamicTranslation($text_orig, $text_locale) { global $zdb; try { $select = $zdb->select(L10n::TABLE); $select->limit(1)->columns(array('text_trans'))->where(array('text_orig' => $text_orig, 'text_locale' => $text_locale)); $results = $zdb->execute($select); if ($results->count() > 0) { $res = $results->current(); return $res->text_trans; } else { return; } } catch (Exception $e) { Analog::log('An error occured retrieving l10n entry. text_orig=' . $text_orig . ', text_locale=' . $text_locale . ' | ' . $e->getMessage(), Analog::WARNING); return false; } }
/** * Setter * * @param string $name Property name * @param mixed $value Property value * * @return void */ public function __set($name, $value) { $rname = '_' . $name; switch ($name) { case 'type': if ($value === self::IMPENDING || $value === self::LATE) { $this->_type = $value; } else { throw new \UnexpectedValueException('Unknown type!'); } break; case 'dest': if ($this->_type !== null && $value instanceof Adherent) { $this->_dest = $value; $this->_replaces['login_adh'] = $value->login; $this->_replaces['name_adh'] = custom_html_entity_decode($value->sname); $this->_replaces['firstname_adh'] = custom_html_entity_decode($value->surname); $this->_replaces['lastname_adh'] = custom_html_entity_decode($value->name); if ($value->email != '') { $this->_nomail = false; } if ($this->_type === self::LATE) { $this->_replaces['days_expired'] = $value->days_remaining * -1; } if ($this->_type === self::IMPENDING) { $this->_replaces['days_remaining'] = $value->days_remaining; } } else { if (!$value instanceof Adherent) { throw new \UnexpectedValueException('Please provide a member object.'); } else { throw new \UnderflowException('Please set reminder type first.'); } } break; default: Analog::log('Unable to set property ' . $name, Analog::WARNING); break; } }
$members = null; if (isset($session['filters']['reminders_labels'])) { $filters = unserialize($session['filters']['reminders_labels']); unset($session['filters']['reminders_labels']); } elseif (isset($session['filters']['members'])) { $filters = unserialize($session['filters']['members']); } else { $filters = new MembersList(); } if (isset($_GET['from']) && $_GET['from'] === 'mailing') { //if we're from mailing, we have to retrieve its unreachables members for labels $mailing = unserialize($session['mailing']); $members = $mailing->unreachables; } else { if (count($filters->selected) == 0) { Analog::log('No member selected to generate labels', Analog::INFO); header('location:gestion_adherents.php'); die; } $m = new Members(); $members = $m->getArrayList($filters->selected, array('nom_adh', 'prenom_adh'), false, true, null, false, false, true); } if (!is_array($members) || count($members) < 1) { die; } $doc_title = _T("Member's Labels"); $doc_subject = _T("Generated by Galette"); $doc_keywords = _T("Labels"); // Create new PDF document $pdf = new Pdf($preferences); // Set document information
$pdf->PageHeader($doc_title); $pdf->SetFont(Pdf::FONT, '', SHEET_FONT); $pdf->SetTextColor(0, 0, 0); $groups = new Groups(); $groups_list = null; if (isset($_GET['gid'])) { $groups_list = $groups->getList(true, $_GET['gid']); } else { $groups_list = $groups->getList(); } //var_dump($groups_list); $first = true; foreach ($groups_list as $group) { $id = $group->getId(); if (!$login->isGroupManager($id)) { Analog::log('Trying to display group ' . $id . ' without appropriate permissions', Analog::INFO); continue; } // Header if ($first === false) { $pdf->ln(5); } $pdf->SetFont('', 'B', SHEET_FONT + 1); $pdf->Cell(190, 4, $group->getName(), 0, 1, 'C'); $pdf->SetFont('', '', SHEET_FONT); $managers_list = $group->getManagers(); $managers = array(); foreach ($managers_list as $m) { $managers[] = $m->sfullname; } if (count($managers) > 0) {
* along with Galette. If not, see <http://www.gnu.org/licenses/>. * * @category Plugins * @package Galette * @author Johan Cwiklinski <*****@*****.**> * @copyright 2011-2014 The Galette Team * @license http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version * @version SVN: $Id$ * @link http://galette.tuxfamily.org * @since Available since 0.7dev - 2011-09-13 */ use Analog\Analog; use Galette\Repository\Members; require_once 'includes/galette.inc.php'; if (!$login->isLogged() || !$login->isAdmin() && !$login->isStaff()) { Analog::log('Trying to display ajax_recipients.php without appropriate permissions', Analog::INFO); die; } $mailing = unserialize($session['mailing']); $m = new Members(); $members = $m->getArrayList($_POST['recipients'], null, false, true, null, false, false, true); $mailing->setRecipients($members); $session['mailing'] = serialize($mailing); //let's generate html for return $html = ''; if (count($mailing->recipients) > 0) { $html = '<p id="recipients_count">' . preg_replace('/%s/', count($mailing->recipients), _T("You are about to send an e-mail to <strong>%s members</strong>")) . '</p>'; if (count($mailing->unreachables)) { $html .= '<p id="unreachables_count"><strong>' . count($mailing->unreachables) . ' ' . (count($mailing->unreachables) != 1 ? _T("unreachable members:") : _T("unreachable member:")) . '</strong><br/>' . _T("Some members you have selected have no e-mail address. However, you can generate envelope labels to contact them by snail mail.") . '<br/><a id="btnlabels" class="button" href="etiquettes_adherents.php?from=mailing">' . _T("Generate labels") . '</a></p>'; } } else {
/** * Perform the logging to Analog after the log level has been converted. */ private function _log($level, $message, $context) { Analog::log($this->interpolate($message, $context), $level); }
/** * Does this login already exists ? * These function should be used for setting admin login into Preferences * * @param string $user the username * * @return true if the username already exists, false otherwise */ public function loginExists($user) { global $zdb; try { $select = $zdb->select(self::TABLE); $select->where(array(self::PK => $user)); $results = $zdb->execute($select); if ($results->count() > 0) { /* We got results, user already exists */ return true; } else { /* No results, user does not exists yet :) */ return false; } } catch (\Exception $e) { Analog::log('Cannot check if login exists | ' . $e->getMessage(), Analog::WARNING); /* If an error occurs, we consider that username already exists */ return true; } }
/** * Get a numeric value sent by a form, either in POST and GET arrays * * @param string $name property name * @param string $defval default rollback value * * @return numeric value retrieved from : * - GET array if defined and numeric, * - POST array if defined and numéric * - $defval otherwise */ function get_numeric_form_value($name, $defval) { $val = get_form_value($name, $defval); if (!is_numeric($val)) { Analog::log('[get_numeric_form_value] not a numeric value! (value was: `' . $val . '`)', Analog::INFO); $val = $defval; } return $val; }
$exists = false; $error_detected[] = str_replace('%s', $text_orig, _T("No translation for '%s'!<br/>Please fill and submit above form to create it.")); } } $trans = array(); /** * FIXME : it would be faster to get all translations at once * for a specific string */ foreach ($i18n->getList() as $l) { $text_trans = getDynamicTranslation($text_orig, $l->getLongID()); $lang_name = $l->getName(); $trans[] = array('key' => $l->getLongID(), 'name' => ucwords($lang_name), 'text' => $text_trans); } $tpl->assign('exists', $exists); $tpl->assign('orig', $orig); $tpl->assign('trans', $trans); } catch (Exception $e) { Analog::log('An error occured retrieving l10n entries | ' . $e->getMessage(), Analog::WARNING); } } $tpl->assign('page_title', _T("Translate labels")); $tpl->assign('text_orig', $text_orig); $tpl->assign('error_detected', $error_detected); $tpl->assign('success_detected', $success_detected); $content = $tpl->fetch('traduire_libelles.tpl'); $tpl->assign('content', $content); $tpl->display('page.tpl'); if (isset($profiler)) { $profiler->stop(); }
if (isset($member->bool_admin_adh)) { $member->bool_admin_adh = $member->bool_admin_adh ? _T("Yes") : _T("No"); } if (isset($member->bool_exempt_adh)) { $member->bool_exempt_adh = $member->bool_exempt_adh ? _T("Yes") : _T("No"); } if (isset($member->bool_display_info)) { $member->bool_display_info = $member->bool_display_info ? _T("Yes") : _T("No"); } } $filename = 'filtered_memberslist.csv'; $filepath = CsvOut::DEFAULT_DIRECTORY . $filename; $fp = fopen($filepath, 'w'); if ($fp) { $res = $csv->export($members_list, Csv::DEFAULT_SEPARATOR, Csv::DEFAULT_QUOTE, $labels, $fp); fclose($fp); $written[] = array('name' => $filename, 'file' => $filepath); } if (file_exists(CsvOut::DEFAULT_DIRECTORY . $filename)) { header('Content-Type: text/csv'); header('Content-Disposition: attachment; filename="' . $filename . '";'); header('Pragma: no-cache'); readfile(CsvOut::DEFAULT_DIRECTORY . $filename); } else { Analog::log('A request has been made to get an exported file named `' . $filename . '` that does not exists.', Analog::WARNING); header('HTTP/1.0 404 Not Found'); } } else { Analog::log('A non authorized person asked to retrieve exported file named `' . $filename . '`. Access ha not been granted.', Analog::WARNING); header('HTTP/1.0 403 Forbidden'); }
/** * Check if input file meet requirements * * @param string $filename File name * * @return boolean */ private function _check($filename) { //deal with mac e-o-l encoding -- see if needed //@ini_set('auto_detect_line_endings', true); $handle = fopen(self::DEFAULT_DIRECTORY . '/' . $filename, 'r'); if (!$handle) { Analog::log('File ' . $filename . ' cannot be open!', Analog::ERROR); $this->addError(str_replace('%filename', $filename, _T('File %filename cannot be open!'))); return false; } if ($handle !== false) { $cnt_fields = count($this->_fields); //check required fields $fc = new FieldsConfig(Adherent::TABLE, $this->_members_fields, $members_fields_cats); $config_required = $fc->getRequired(); $this->_required = array(); foreach (array_keys($config_required) as $field) { if (in_array($field, $this->_fields)) { $this->_required[$field] = $field; } } $row = 0; while (($data = fgetcsv($handle, 1000, self::DEFAULT_SEPARATOR, self::DEFAULT_QUOTE)) !== false) { //check fields count $count = count($data); if ($count != $cnt_fields) { $this->addError(str_replace(array('%should_count', '%count', '%row'), array($cnt_fields, $count, $row), _T("Fields count mismatch... There should be %should_count fields and there are %count (row %row)"))); return false; } //check required fields if ($row > 0) { //header line is the first one. Here comes data $col = 0; foreach ($data as $column) { if (in_array($this->_fields[$col], $this->_required) && trim($column) == '') { $this->addError(str_replace(array('%field', '%row'), array($this->_fields[$col], $row), _T("Field %field is required, but missing in row %row"))); return false; } $col++; } } $row++; } fclose($handle); if (!($row > 1)) { //no data in file, just headers line $this->addError(_T("File is empty!")); return false; } else { return true; } } return false; }
/** * Global setter method * * @param string $name name of the property we want to assign a value to * @param object $value a relevant value for the property * * @return void */ public function __set($name, $value) { //does this pref exists ? if (!array_key_exists($name, self::$_defaults)) { Analog::log('Trying to set a preference value which does not seem to exist (' . $name . ')', Analog::WARNING); return false; } //some values need to be changed (eg. passwords) if ($name == 'pref_admin_pass') { $value = password_hash($value, PASSWORD_BCRYPT); } //okay, let's update value $this->_prefs[$name] = $value; }
* * You should have received a copy of the GNU General Public License * along with Galette. If not, see <http://www.gnu.org/licenses/>. * * @category Plugins * @package Galette * @author Johan Cwiklinski <*****@*****.**> * @copyright 2011-2014 The Galette Team * @license http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version * @version SVN: $Id$ * @link http://galette.tuxfamily.org * @since Available since 0.7dev - 2011-10-29 */ use Analog\Analog; use Galette\Repository\Members; require_once 'includes/galette.inc.php'; $ids = $_POST['persons']; $mode = $_POST['person_mode']; if (!$ids || !$mode) { Analog::log('Trying to display ajax_group_members.php without persons or mode specified', Analog::INFO); die; } if (!$login->isLogged() || !$login->isAdmin() && !$login->isStaff()) { Analog::log('Trying to display ajax_group_members.php without appropriate permissions', Analog::INFO); die; } $m = new Members(); $persons = $m->getArrayList($ids); $tpl->assign('persons', $persons); $tpl->assign('person_mode', $mode); $tpl->display('group_persons.tpl');
case 'groups': if (!isset($_POST['gid'])) { Analog::log('Trying to list group members with no group id provided', Analog::ERROR); throw new Exception('A group id is required.'); exit(0); } if (!isset($_POST['members'])) { $group = new Group((int) $_POST['gid']); $selected_members = array(); if (!isset($_POST['mode']) || $_POST['mode'] == 'members') { $selected_members = $group->getMembers(); } else { if ($_POST['mode'] == 'managers') { $selected_members = $group->getManagers(); } else { Analog::log('Trying to list group members with unknown mode', Analog::ERROR); throw new Exception('Unknown mode.'); exit(0); } } } else { $m = new Members(); $selected_members = $m->getArrayList($_POST['members']); } break; case 'attach': if (!isset($_POST['id_adh'])) { throw new \RuntimeException('Current selected member must be excluded while attaching!'); exit(0); } else { $tpl->assign('excluded', $_POST['id_adh']);