本文整理汇总了PHP中Module::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Module::find方法的具体用法?PHP Module::find怎么用?PHP Module::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Module
的用法示例。
在下文中一共展示了Module::find方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getControllerActions
/**
* For listing the Module Role table data
* @author Praveen Singh
* @method getModuleRoleData
* @param $id
* @return one row of Module Role table
* @since version 0.0.1
* @version 0.2.9
*/
function getControllerActions($controllerID)
{
App::import("Model", "Module");
$model = new Module();
$datas = $model->find("all", array('conditions' => array('Module.parent_id' => $controllerID)));
return $datas;
}
示例2: __construct
function __construct()
{
parent::__construct();
$this->view_data['core_settings'] = Setting::first();
if ($this->input->cookie('language') != "") {
$language = $this->input->cookie('language');
} else {
if (isset($this->view_data['language'])) {
$language = $this->view_data['language'];
} else {
if (!empty($this->view_data['core_settings']->language)) {
$language = $this->view_data['core_settings']->language;
} else {
$language = "english";
}
}
}
$this->lang->load('application', $language);
$this->lang->load('messages', $language);
$this->lang->load('event', $language);
$this->user = $this->session->userdata('user_id') ? User::find_by_id($this->session->userdata('user_id')) : FALSE;
$this->client = $this->session->userdata('client_id') ? Client::find_by_id($this->session->userdata('client_id')) : FALSE;
if ($this->client) {
$this->theme_view = 'application_client';
}
$this->view_data['datetime'] = date('Y-m-d H:i', time());
$this->view_data['sticky'] = Project::all(array('conditions' => 'sticky = 1'));
$this->view_data['quotations_new'] = Quote::find_by_sql("select count(id) as amount from quotations where status='New'");
if ($this->user || $this->client) {
$access = $this->user ? $this->user->access : $this->client->access;
$access = explode(",", $access);
if ($this->user) {
$this->view_data['menu'] = Module::find('all', array('order' => 'sort asc', 'conditions' => array('id in (?) AND type = ?', $access, 'main')));
$this->view_data['widgets'] = Module::find('all', array('conditions' => array('id in (?) AND type = ?', $access, 'widget')));
} else {
$this->view_data['menu'] = Module::find('all', array('order' => 'sort asc', 'conditions' => array('id in (?) AND type = ?', $access, 'client')));
}
if ($this->user) {
$update = User::find($this->user->id);
} else {
$update = Client::find($this->client->id);
}
$update->last_active = time();
$update->save();
if ($this->user) {
$this->view_data['user_online'] = User::all(array('conditions' => array('last_active+(30 * 60) > ? AND status = ?', time(), "active")));
$this->view_data['client_online'] = Client::all(array('conditions' => array('last_active+(30 * 60) > ? AND inactive = ?', time(), "0")));
}
$email = $this->user ? 'u' . $this->user->id : 'c' . $this->client->id;
$this->view_data['messages_new'] = Privatemessage::find_by_sql("select count(id) as amount from privatemessages where `status`='New' AND recipient = '" . $email . "'");
$this->view_data['tickets_new'] = Ticket::find_by_sql("select count(id) as amount from tickets where `status`='New'");
}
/*$this->load->database();
$sql = "select * FROM templates WHERE type='notes'";
$query = $this->db->query($sql); */
$this->view_data["note_templates"] = "";
//$query->result();
}
示例3: index
function index()
{
$core_settings = Setting::first();
if ($core_settings->registration != 1) {
redirect('login');
}
if ($_POST) {
$this->load->library('parser');
$this->load->helper('file');
$this->load->helper('notification');
$client = Client::find_by_email($_POST['email']);
if ($client->inactive == 1) {
$client = FALSE;
}
$check_company = Company::find_by_name($_POST['name']);
if (!$client && !$check_company && $_POST['name'] != "" && $_POST['email'] != "" && $_POST['password'] != "" && $_POST['firstname'] != "" && $_POST['lastname'] != "" && $_POST['confirmcaptcha'] != "") {
$client_attr = array();
$company_attr['name'] = $_POST['name'];
$company_attr['website'] = $_POST['website'];
$company_attr['phone'] = $_POST['phone'];
$company_attr['mobile'] = $_POST['mobile'];
$company_attr['address'] = $_POST['address'];
$company_attr['zipcode'] = $_POST['zipcode'];
$company_attr['city'] = $_POST['city'];
$company_attr['country'] = $_POST['country'];
$company_attr['province'] = $_POST['province'];
$company_attr['vat'] = $_POST['vat'];
$company_attr['reference'] = $core_settings->company_reference;
$core_settings->company_reference = $core_settings->company_reference + 1;
$core_settings->save();
$company = Company::create($company_attr);
if (!$company) {
$this->session->set_flashdata('message', 'success:' . $this->lang->line('messages_registration_error'));
redirect('register');
}
$lastclient = Client::last();
$client_attr = array();
$client_attr['email'] = $_POST['email'];
$client_attr['firstname'] = $_POST['firstname'];
$client_attr['lastname'] = $_POST['lastname'];
$client_attr['phone'] = $_POST['phone'];
$client_attr['mobile'] = $_POST['mobile'];
$client_attr['address'] = $_POST['address'];
$client_attr['zipcode'] = $_POST['zipcode'];
$client_attr['city'] = $_POST['city'];
$modules = Module::find('all', array('order' => 'sort asc', 'conditions' => array('type = ?', 'client')));
$client_attr['access'] = "";
foreach ($modules as $value) {
if ($value->name == "Projects" || $value->name == "Messages" || $value->name == "Tickets" || $value->name == "Invoices") {
$client_attr['access'] .= $value->id . ",";
}
}
$client_attr['company_id'] = $company->id;
$client = Client::create($client_attr);
if ($client) {
$client->password = $client->set_password($_POST['password']);
$client->save();
$company->client_id = $client->id;
$company->save();
$this->email->from($core_settings->email, $core_settings->company);
$this->email->to($client_attr['email']);
$this->email->subject($this->lang->line('application_your_account_has_been_created'));
$parse_data = array('link' => base_url() . 'login/', 'company' => $core_settings->company, 'company_reference' => $company->reference, 'logo' => '<img src="' . base_url() . '' . $core_settings->logo . '" alt="' . $core_settings->company . '"/>', 'invoice_logo' => '<img src="' . base_url() . '' . $core_settings->invoice_logo . '" alt="' . $core_settings->company . '"/>');
$email = read_file('./application/views/' . $core_settings->template . '/templates/email_create_account.html');
$message = $this->parser->parse_string($email, $parse_data);
$this->email->message($message);
$this->email->send();
send_notification($core_settings->email, $this->lang->line('application_new_client_has_registered'), $this->lang->line('application_new_client_has_registered') . ': <br><strong>' . $company_attr['name'] . '</strong><br>' . $client_attr['firstname'] . ' ' . $client_attr['lastname'] . '<br>' . $client_attr['email']);
$this->session->set_flashdata('message', 'success:' . $this->lang->line('messages_registration_success'));
redirect('login');
} else {
$this->session->set_flashdata('message', 'success:' . $this->lang->line('messages_registration_error'));
redirect('login');
}
} else {
$this->view_data['error'] = $this->lang->line('messages_email_already_taken');
$this->theme_view = 'login';
$this->content_view = 'auth/register';
$this->view_data['form_action'] = 'register';
$this->view_data['registerdata'] = $_POST;
}
} else {
$this->view_data['error'] = 'false';
$this->theme_view = 'login';
$this->content_view = 'auth/register';
$this->view_data['form_action'] = 'register';
}
}
示例4: update
function update($id = FALSE, $getview = FALSE)
{
if ($_POST) {
$id = $_POST['id'];
$client = Client::find($id);
$config['upload_path'] = './files/media/';
$config['encrypt_name'] = TRUE;
$config['allowed_types'] = 'gif|jpg|png';
$config['max_width'] = '180';
$config['max_height'] = '180';
$this->load->library('upload', $config);
if ($this->upload->do_upload()) {
$data = array('upload_data' => $this->upload->data());
$_POST['userpic'] = $data['upload_data']['file_name'];
} else {
$error = $this->upload->display_errors('', ' ');
if ($error != "You did not select a file to upload. ") {
$this->session->set_flashdata('message', 'error:' . $error);
redirect('clients');
}
}
unset($_POST['send']);
unset($_POST['userfile']);
unset($_POST['file-name']);
if (empty($_POST["password"])) {
unset($_POST['password']);
} else {
$_POST['password'] = $client->set_password($_POST['password']);
}
if (!empty($_POST["access"])) {
$_POST["access"] = implode(",", $_POST["access"]);
}
if (isset($_POST['view'])) {
$view = $_POST['view'];
unset($_POST['view']);
}
$_POST = array_map('htmlspecialchars', $_POST);
$client->update_attributes($_POST);
if (!$client) {
$this->session->set_flashdata('message', 'error:' . $this->lang->line('messages_save_client_error'));
} else {
$this->session->set_flashdata('message', 'success:' . $this->lang->line('messages_save_client_success'));
}
redirect('clients/view/' . $client->company->id);
} else {
$this->view_data['client'] = Client::find($id);
$this->view_data['modules'] = Module::find('all', array('order' => 'sort asc', 'conditions' => array('type = ?', 'client')));
if ($getview == "view") {
$this->view_data['view'] = "true";
}
$this->theme_view = 'modal';
$this->view_data['title'] = $this->lang->line('application_edit_client');
$this->view_data['form_action'] = 'clients/update';
$this->content_view = 'clients/_clients';
}
}
示例5: find
/**
* @overrride
* @see Module::find()
*/
public function find($colsname)
{
parent::find($colsname);
$this->updateSession();
}
示例6: register_theme_directory
/**
* @package Hello_Dolly
* @version 1.6
*/
/*
Plugin Name: INIT
Plugin URI:
Description: System Init
Author: Mo
Version: 1.1
Author URI: http://mo.sh/
*/
register_theme_directory(__DIR__);
foreach (Module::all() as $name => $module) {
if (Module::find($name)->json()->type == 'theme') {
register_theme_directory(dirname($module->getpath()));
//kd($module->getpath());
}
}
//add_filter('theme_root',function($theme_root){
// return __DIR__;
//});
//add_filter('theme_root_uri',function($theme_root_uri = '', $siteurl = '', $stylesheet_or_template = ''){
// kd($theme_root_uri, $siteurl, $stylesheet_or_template);
// return content_url();
//});
show_admin_bar(false);
// 上传图片时把绝对地址修改成相对地址(禁用,导致上传文件http错误)
//add_filter('wp_handle_upload', function ($fileInfos){
// global $blog_id;
示例7: user_update
function user_update($user = FALSE)
{
$user = User::find($user);
if ($_POST) {
$config['upload_path'] = './files/media/';
$config['encrypt_name'] = TRUE;
$config['allowed_types'] = 'gif|jpg|jpeg|png';
$config['max_width'] = '180';
$config['max_height'] = '180';
$this->load->library('upload', $config);
if ($this->upload->do_upload()) {
$data = array('upload_data' => $this->upload->data());
$_POST['userpic'] = $data['upload_data']['file_name'];
}
unset($_POST['file-name']);
unset($_POST['send']);
unset($_POST['confirm_password']);
if (!empty($_POST["access"])) {
$_POST["access"] = implode(",", $_POST["access"]);
}
$_POST = array_map('htmlspecialchars', $_POST);
if (empty($_POST['password'])) {
unset($_POST['password']);
}
if ($_POST['admin'] == "0" && $_POST['username'] == "Admin") {
$_POST['admin'] = "1";
}
$user->update_attributes($_POST);
$this->session->set_flashdata('message', 'success:' . $this->lang->line('messages_save_user_success'));
redirect('settings/users');
} else {
$this->view_data['user'] = $user;
$this->theme_view = 'modal';
$this->view_data['modules'] = Module::find('all', array('order' => 'sort asc', 'conditions' => array('type != ?', 'client')));
$this->view_data['title'] = $this->lang->line('application_edit_user');
$this->view_data['form_action'] = 'settings/user_update/' . $user->id;
$this->content_view = 'settings/_userform';
}
}
示例8: delete_destroy
public function delete_destroy($object_id = false)
{
$module = Module::find($object_id);
$module->delete();
return Redirect::to_action('modules@index');
}
示例9: changeState
public static function changeState($id, $state)
{
$module = Module::find($id);
$module->enabled = $state;
$module->save();
}
示例10: getDelete
public function getDelete($id)
{
// Find the module using the user id
$module = Module::find($id);
if ($module == null) {
$errors = new \Illuminate\Support\MessageBag();
$errors->add('deleteError', "We are having problem deleting this entry. Please try again.");
return \Redirect::to('admin/modules')->withErrors($errors);
}
$purchases = UserPricelist::join('pricelists', 'pricelists.id', '=', 'user_pricelists.pricelist_id')->where('pricelists.module_id', $id)->get();
if (count($purchases) > 0) {
$errors = new \Illuminate\Support\MessageBag();
$errors->add('deleteError', "This module has been purchased before. You cannot delete it. Please change disable it instead.");
return \Redirect::to('admin/modules')->withErrors($errors);
}
// Delete all images first
$module->deleteAllImages();
// Delete all tags
$module->deleteAllTags();
// Delete all pricelist
foreach (Pricelist::where('module_id', $id)->get() as $pricelist) {
$pricelist->delete();
}
// Delete all media links
foreach (ModuleMediaMembership::where('module_id', $id)->get() as $mmm) {
$mmm->delete();
}
// Delete the module
$module->delete();
return \Redirect::to('admin/modules');
}
示例11: parse
/**
* Procesa la url indicando que es lo que se espera obtener según las
* rutas que existen conectadas
* @todo Buscar forma de reducir este método pero manteniendo las mismas funcionalidades del parser
* @author Esteban De La Fuente Rubio, DeLaF (esteban[at]delaf.cl)
* @version 2014-04-17
*/
public static function parse($url)
{
// La url requiere partir con "/", si no lo tiene se coloca
if (empty($url) || $url[0] != '/') {
$url = '/' . $url;
}
// Si existe una ruta para la url que se está revisando se carga su configuración
if (isset(self::$routes[$url])) {
return self::routeNormalize(self::$routes[$url]);
}
// buscar página estática
if (self::$autoStaticPages && ($params = self::parseStaticPage($url)) !== false) {
return $params;
}
// buscar página estática nuevamente, pero esta vez dentro del módulo (si existe)
$module = Module::find($url);
if (self::$autoStaticPages && ($params = self::parseStaticPage(self::urlClean($url, $module), $module)) !== false) {
return $params;
}
// Buscar alguna que sea parcial (:controller, :action o *)
foreach (self::$routes as $key => $aux) {
$params = array_merge(array('module' => null, 'controller' => null, 'action' => null, 'pass' => null), $aux);
// Tiene :controller
$controller = strpos($key, ':controller');
if ($controller) {
$inicioKey = rtrim(substr($key, 0, $controller), '/');
// Si la URL parte con lo que está antes de :controler
if (strpos($url, $inicioKey) === 0) {
$ruta = ltrim(str_replace($inicioKey, '', $url), '/');
$partes = explode('/', $ruta);
$params['controller'] = array_shift($partes);
if (empty($params['action'])) {
$params['action'] = count($partes) ? array_shift($partes) : 'index';
}
$params['pass'] = $partes;
return $params;
} else {
continue;
}
}
// No tiene :controller, pero si :action
$action = strpos($key, ':action');
if ($action) {
$inicioKey = rtrim(substr($key, 0, $action), '/');
// Si la URL parte con lo que está antes de :action
if (strpos($url, $inicioKey) === 0) {
$ruta = ltrim(str_replace($inicioKey, '', $url), '/');
if (strlen($ruta)) {
$partes = explode('/', $ruta);
if (empty($params['action'])) {
$params['action'] = count($partes) ? array_shift($partes) : 'index';
}
$params['pass'] = $partes;
} else {
$params['action'] = 'index';
$params['pass'] = array();
}
return $params;
} else {
continue;
}
}
// Si no esta el tag :controler ni el de :action se busca si termina en *
if ($key[strlen($key) - 1] == '*') {
$ruta = substr($key, 0, -1);
// Si se encuentra la ruta al inicio de la url
if (strpos($url, $ruta) === 0) {
$params['pass'] = explode('/', str_replace($ruta, '', $url));
return $params;
}
}
}
// Procesar la URL recibida, en el formato /modulo(s)/controlador/accion/parámetro1/parámetro2/etc
$url = self::urlClean($url, $module);
// Arreglo por defecto para los datos de módulo, controlador, accion y parámetros pasados
$params = array('module' => $module, 'controller' => null, 'action' => 'index', 'pass' => null);
// Separar la url solicitada en partes separadas por los "/"
$partes = explode('/', $url);
// quitar primer elemento que es vacio, ya que el string parte con "/"
array_shift($partes);
$params['controller'] = array_shift($partes);
$params['action'] = count($partes) ? array_shift($partes) : 'index';
$params['pass'] = $partes;
// Si no hay controlador y es un módulo se asigna un controlador estándar para cargar la página con el menú del modulo
if (empty($params['controller']) && !empty($params['module'])) {
$params['controller'] = 'module';
$params['action'] = 'display';
}
// Retornar url procesada
return $params;
}
示例12: _asset
/**
* Busca si lo solicitado existe físicamente en el servidor y lo entrega
* @param url Ruta de los que se está solicitando
* @param response Objeto Response
* @return Verdadero si lo solicitado existe dentro de /webroot
* @author Esteban De La Fuente Rubio, DeLaF (esteban[at]delaf.cl)
* @version 2014-03-21
*/
private static function _asset($url, Network_Response $response)
{
// Si la URL es vacía se retorna falso
if ($url == '') {
return false;
}
// Inicializar el archivo como null
$assetFile = null;
// Buscar el archivo en los posibles directorios webroot, incluyendo
// los paths de los modulos
$paths = null;
// si hay más de dos slash en la url podría ser un módulo así que se
// busca path para el modulo
$slashPos = strpos($url, '/', 1);
if ($slashPos) {
// paths de plugins
$module = Module::find($url);
if (isset($module[0])) {
Module::load($module);
$paths = Module::paths($module);
}
// si existe el módulo en los paths entonces si es un módulo lo que
// se está pidiendo, y es un módulo ya cargado. Si este no fuera el
// caso podría no ser plugin, o no estar cargado
if ($paths) {
$removeCount = count(explode('.', $module)) + 1;
$aux = explode('/', $url);
while ($removeCount-- > 0) {
array_shift($aux);
}
$url = '/' . implode('/', $aux);
}
}
// si no está definido el path entonces no era de módulo y se deberá
// buscar en los paths de la aplicación
if (!$paths) {
$paths = App::paths();
}
// en cada paths encontrado buscar el archivo solicitado
foreach ($paths as &$path) {
$file = $path . '/webroot' . $url;
if (file_exists($file) && !is_dir($file)) {
$assetFile = $file;
break;
}
}
// Si se encontró el archivo se envía al cliente
if ($assetFile !== null) {
// Solo se entrega mediante PHP si el archivo no está en
// DIR_WEBSITE/webroot
if (!strpos($assetFile, DIR_WEBSITE) !== false) {
$response->sendFile($assetFile);
}
return true;
}
// Si no se encontró se retorna falso
return false;
}