本文整理汇总了PHP中Meta::first方法的典型用法代码示例。如果您正苦于以下问题:PHP Meta::first方法的具体用法?PHP Meta::first怎么用?PHP Meta::first使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Meta
的用法示例。
在下文中一共展示了Meta::first方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: verify
/**
* @before _session
*/
public function verify($id)
{
$this->seo(array("title" => "Thanks for Registering", "view" => $this->getLayoutView()));
$view = $this->getActionView();
$meta = Meta::first(array("value = ?" => $id, "property = ?" => "forgotPass"));
if (!$meta) {
$this->redirect("/404");
}
$user = User::first(array("id = ?" => $meta->user_id));
if ($user) {
$view->set("message", "Please create a password");
} else {
$this->redirect("/login.html");
}
if (RequestMethods::post("action") == "setpass") {
if (!$user->validate()) {
$view->set("message", "Fields are required");
return;
}
if (RequestMethods::post("password") == RequestMethods::post("rpassword")) {
$user->password = sha1(RequestMethods::post("password"));
$user->live = 1;
$user->save();
$this->setUser($user);
$meta->delete();
$this->redirect("/patient/profile");
} else {
$view->set("message", "Password doesnot match");
}
}
}
示例2: play
/**
* @before _secure
*/
public function play()
{
$this->seo(array("title" => "Play Game", "view" => $this->getLayoutView()));
$view = $this->getActionView();
$session = Registry::get("session");
$campaign = $session->get('Game\\Authorize:$campaign');
if (!$campaign) {
$this->redirect("/index.html");
}
$session->erase('Game\\Authorize:$campaign');
$model = $campaign->type;
$game = $model::first(array("id = ?" => $campaign->type_id));
switch ($model) {
case 'imagetext':
$img = $this->_imagetextprocess($game, $campaign);
break;
case 'image':
$img = $this->_imageprocess($game, $campaign);
break;
case 'text':
$img = $this->_textprocess($game, $campaign);
break;
case 'shuffle':
$img = $this->_shuffleprocess($game, $campaign);
break;
}
$participant = Participant::first(array("user_id = ?" => $this->user->id, "campaign_id = ?" => $campaign->id));
$facebook = new Curl();
$facebook->post('https://graph.facebook.com/?id=' . "http://" . $_SERVER["HTTP_HOST"] . "/game/result/" . $participant->id . '&scrape=true');
$facebook->close();
$domain = Meta::first(array("property = ?" => "domain", "live = ?" => true));
$items = Participant::all(array(), array("DISTINCT campaign_id"), "created", "desc", 3, 1);
$view->set("items", $items);
$view->set("img", $img);
$view->set("participant", $participant);
$view->set("campaign", $campaign)->set("domain", $domain);
}
示例3: __construct
public function __construct($options = array())
{
parent::__construct($options);
// connect to database
$database = Registry::get("database");
$database->connect();
$mongoDB = Registry::get("MongoDB");
if (!$mongoDB) {
$mongo = new \MongoClient();
$mongoDB = $mongo->selectDB("stats");
Registry::set("MongoDB", $mongoDB);
}
$session = Registry::get("session");
$fbapp = $session->get("fbapp");
if (!$fbapp) {
$fbapp = \Meta::first(array("property = ?" => "fbapp"))->value;
$session->set("fbapp", $fbapp);
}
$this->getLayoutView()->set("fbapp", $fbapp);
// schedule: load user from session
Events::add("framework.router.beforehooks.before", function ($name, $parameters) {
$session = Registry::get("session");
$controller = Registry::get("controller");
$user = $session->get("user");
if ($user) {
$controller->user = \User::first(array("id = ?" => $user));
}
});
// schedule: save user to session
Events::add("framework.router.afterhooks.after", function ($name, $parameters) {
$session = Registry::get("session");
$controller = Registry::get("controller");
if ($controller->user) {
$session->set("user", $controller->user->id);
}
});
// schedule: disconnect from database
Events::add("framework.controller.destruct.after", function ($name) {
$database = Registry::get("database");
$database->disconnect();
});
}
示例4: _meta
/**
* Sets the meta for app login
*/
private function _meta($user, $app)
{
$meta = Meta::first(array("property = ?" => "user", "property_id = ?" => $user->id, "meta_key = ?" => $app . "-app"));
if (!$meta) {
$meta = new Meta(array("property" => "user", "property_id" => $user->id, "meta_key" => $app . "-app", "meta_value" => Markup::uniqueString(44)));
$meta->save();
}
return $meta;
}
示例5: settings
/**
* @before _secure
* @after _csrfToken
*/
public function settings()
{
$this->seo(array("title" => "Settings"));
$view = $this->getActionView();
$user = $this->user;
$org = $this->org;
$search = ['prop' => 'customField', 'propid' => $org->_id];
$meta = Meta::first($search) ?? (object) [];
$view->set('fields', $meta->value ?? []);
$apikey = ApiKey::first(["org_id = ?" => $org->id]);
$mailConf = Meta::first(['prop' => 'orgSmtp', 'propid' => $this->org->_id]) ?? (object) [];
$view->set('mailConf', $mailConf->value ?? [])->set("errors", []);
if (RM::type() == 'POST') {
$action = RM::post('action', '');
switch ($action) {
case 'account':
$user->name = RM::post('name');
$user->currency = RM::post('currency', 'INR');
$user->region = ["currency" => RM::post('currency', 'INR'), "zone" => RM::post('timezone', 'Asia/Kolkata')];
$user->phone = RM::post('phone');
$user->save();
$view->set('message', 'Account Updated!!');
break;
case 'password':
$old = RM::post('password');
$new = RM::post('npassword');
$view->set($user->updatePassword($old, $new));
break;
case 'billing':
$billing = $org->billing;
$billing["aff"]["auto"] = RM::post("autoinvoice", 0);
$billing["aff"]["freq"] = RM::post("freq", 15);
$billing["aff"]["minpay"] = $this->currency(RM::post('minpay', 100));
$billing["aff"]["ptypes"] = RM::post("ptypes");
$billing["adv"]["paypal"] = RM::post("paypal");
$org->billing = $billing;
$org->save();
$this->setOrg($org);
$view->set('message', 'Organization Billing Updated!!');
break;
case 'org':
$meta = $org->meta;
if (RM::post("widgets")) {
$meta["widgets"] = RM::post("widgets");
$org->meta = $meta;
}
$zopim = RM::post("zopim");
$meta["zopim"] = $zopim;
if (strlen($zopim) == 0) {
unset($meta["zopim"]);
}
$org->name = RM::post('name');
$org->meta = $meta;
$org->logo = $this->_upload('logo');
$org->url = RM::post('url');
$org->email = RM::post('email');
$org->save();
$this->setOrg($org);
$view->set('message', 'Network Settings updated!!');
break;
case 'customField':
$label = RM::post("fname");
$type = RM::post("ftype", "text");
$required = RM::post("frequired", 1);
$name = strtolower(str_replace(" ", "_", $label));
$field = ['label' => ucwords($label), 'type' => $type, 'name' => $name, 'required' => (bool) $required];
if (!$label) {
break;
}
if (!is_object($meta) || !is_a($meta, 'Meta')) {
$meta = new Meta($search);
}
$fields = $meta->value;
$fields[] = $field;
$meta->value = $fields;
$meta->save();
$view->set('fields', $meta->value ?? []);
$view->set('message', 'Extra Field Added!!');
break;
case 'smtp':
$msg = \Shared\Services\Smtp::create($this->org);
$view->set('message', $msg);
break;
case 'apikey':
$view->set('message', "Api Key Updated!!");
if (!$apikey) {
$apikey = new ApiKey(['org_id' => $this->org->_id, 'key' => uniqid() . uniqid() . uniqid()]);
$view->set('message', "Api Key Created!!");
}
$apikey->updateIps();
$apikey->save();
break;
}
$this->setUser($user);
}
$view->set("apiKey", $apikey);
//.........这里部分代码省略.........
示例6: verify
/**
* Verifies the doctor and allows them to change or create password
* @before _session
*/
public function verify($id)
{
$this->seo(array("title" => "Thanks for Registering", "view" => $this->getLayoutView()));
$view = $this->getActionView();
$meta = Meta::first(array("value = ?" => $id, "property = ?" => "forgotPass"));
if (!$meta) {
$this->redirect("/404");
}
$user = User::first(array("id = ?" => $meta->user_id));
if ($user) {
$view->set("message", "Please create a password");
} else {
$this->redirect("/");
}
if (RequestMethods::post("action") == "setpass") {
if (!$user->validate()) {
$view->set("message", "Fields are required");
return;
}
if (RequestMethods::post("password") == RequestMethods::post("rpassword")) {
$user->password = sha1(RequestMethods::post("password"));
$user->live = 1;
$user->save();
$this->setUser($user);
$doctor = Doc::first(array("user_id = ?" => $user->id));
$member = Member::first(array("user_id = ?" => $this->user->id));
$organization = Organization::first(array("id = ?" => $member->organization_id));
Registry::get("session")->set("doctor", $doctor)->set("member", $member)->set("organization", $organization);
$meta->delete();
$this->redirect("/doctor");
} else {
$view->set("message", "Password doesnot match");
}
}
}
示例7: _meta
/**
* Sets the meta for app login
*/
private function _meta($user, $app)
{
$meta = Meta::first(array("user_id = ?" => $user->id, "property = ?" => $app . "-app"));
if (!$meta) {
$meta = new Meta(array("user_id" => $user->id, "property" => $app . "-app", "value" => uniqid()));
$meta->save();
}
return $meta;
}