コード例 #1
0
ファイル: File.php プロジェクト: nabble/ajde
 protected function _getHtmlAttributes()
 {
     $attributes = [];
     $attributes['type'] = 'hidden';
     $attributes['value'] = Ajde_Component_String::escape($this->getValue());
     return $attributes;
 }
コード例 #2
0
ファイル: File.php プロジェクト: nabble/updatemybrowser-v1
 protected function _getHtmlAttributes()
 {
     $attributes = '';
     $attributes .= ' type="hidden" ';
     $attributes .= ' value="' . Ajde_Component_String::escape($this->getValue()) . '" ';
     return $attributes;
 }
コード例 #3
0
ファイル: Image.php プロジェクト: nabble/ajde
 public function process()
 {
     switch ($this->_attributeParse()) {
         case 'base64':
             $image = new Ajde_Resource_Image($this->attributes['filename']);
             $image->setWidth(issetor($this->attributes['width']));
             $image->setHeight(issetor($this->attributes['height']));
             $image->setCrop(Ajde_Component_String::toBoolean(issetor($this->attributes['crop'], true)));
             $controller = Ajde_Controller::fromRoute(new Ajde_Core_Route('_core/component:imageBase64'));
             $controller->setImage($image);
             $controller->setWidth(issetor($this->attributes['width'], null));
             $controller->setHeight(issetor($this->attributes['height'], null));
             $controller->setExtraClass(issetor($this->attributes['class'], ''));
             return $controller->invoke();
             break;
         case 'html':
             return self::getImageTag($this->attributes['filename'], issetor($this->attributes['width']), issetor($this->attributes['height']), Ajde_Component_String::toBoolean(issetor($this->attributes['crop'], true)), issetor($this->attributes['class'], ''), issetor($this->attributes['lazy'], false), issetor($this->attributes['absoluteUrl'], false));
             break;
         case 'image':
             return false;
             break;
     }
     // TODO:
     throw new Ajde_Component_Exception('Missing required attributes for component call');
 }
コード例 #4
0
ファイル: Cookie.php プロジェクト: nabble/ajde
 protected function writer()
 {
     if ($this->_secure) {
         return Ajde_Component_String::encrypt(serialize($this->values()));
     } else {
         return serialize($this->values());
     }
 }
コード例 #5
0
ファイル: Date.php プロジェクト: nabble/updatemybrowser-v1
 protected function _getHtmlAttributes()
 {
     $attributes = '';
     $attributes .= ' type="text" ';
     $attributes .= ' value="' . Ajde_Component_String::escape($this->getValue()) . '" ';
     if ($this->hasReadonly() && $this->getReadonly() === true) {
         $attributes .= ' readonly="readonly" ';
     }
     return $attributes;
 }
コード例 #6
0
ファイル: Timespan.php プロジェクト: nabble/ajde
 protected function _getHtmlAttributes()
 {
     $attributes = [];
     $attributes['type'] = 'hidden';
     $attributes['value'] = Ajde_Component_String::escape($this->getValue());
     if ($this->hasReadonly() && $this->getReadonly() === true) {
         $attributes['readonly'] = 'readonly';
     }
     return $attributes;
 }
コード例 #7
0
ファイル: Publish.php プロジェクト: nabble/ajde
 protected function _getHtmlAttributes()
 {
     $attributes = [];
     $attributes['type'] = 'hidden';
     if ($this->getMode() === self::MODE_NEW) {
         $attributes['value'] = $this->getDefault();
     } else {
         $attributes['value'] = Ajde_Component_String::escape($this->getValue());
     }
     return $attributes;
 }
コード例 #8
0
ファイル: Paypal.php プロジェクト: nabble/ajde
 public function getRedirectParams($description = null)
 {
     $transaction = $this->getTransaction();
     // NOOOO.. THE UGLY HACKING
     $return = config('app.rootUrl') . 'presale/transaction:complete';
     $method = $transaction->shipment_method;
     if ($method == 'presale-remainder') {
         $return = config('app.rootUrl') . 'presale/transaction:confirm_complete';
     }
     return ['cmd' => '_xclick', 'business' => config('shop.transaction.paypal.account'), 'notify_url' => config('app.rootUrl') . $this->returnRoute . 'paypal' . $this->getMethod() . '.html', 'bn' => config('app.id') . '_BuyNow_WPS_' . strtoupper(Ajde_Lang::getInstance()->getShortLang()), 'amount' => $transaction->payment_amount, 'item_name' => issetor($description, config('app.title') . ': ' . Ajde_Component_String::makePlural($transaction->shipment_itemsqty, 'item')), 'quantity' => 1, 'address_ override' => 1, 'address1' => $transaction->shipment_address, 'zip' => $transaction->shipment_zipcode, 'city' => $transaction->shipment_city, 'state' => $transaction->shipment_region, 'country' => $transaction->shipment_country, 'email' => $transaction->email, 'first_name' => $transaction->name, 'currency_code' => config('shop.currency.code'), 'custom' => $transaction->secret, 'no_shipping' => 1, 'no_note' => 1, 'return' => $return, 'rm' => 1];
 }
コード例 #9
0
ファイル: Numeric.php プロジェクト: nabble/ajde
 protected function _getHtmlAttributes()
 {
     $attributes = [];
     $attributes['type'] = 'number';
     $attributes['step'] = 'any';
     $attributes['value'] = Ajde_Component_String::escape($this->getValue());
     $attributes['maxlength'] = $this->getLength();
     if ($this->getIsAutoIncrement() === true || $this->hasReadonly() && $this->getReadonly() === true) {
         $attributes['readonly'] = 'readonly';
     }
     return $attributes;
 }
コード例 #10
0
ファイル: Numeric.php プロジェクト: nabble/updatemybrowser-v1
 protected function _getHtmlAttributes()
 {
     $attributes = '';
     $attributes .= ' type="number" ';
     $attributes .= ' step="any" ';
     $attributes .= ' value="' . Ajde_Component_String::escape($this->getValue()) . '" ';
     $attributes .= ' maxlength="' . $this->getLength() . '" ';
     if ($this->getIsAutoIncrement() === true) {
         $attributes .= ' readonly="readonly" ';
     }
     return $attributes;
 }
コード例 #11
0
ファイル: Time.php プロジェクト: nabble/ajde
 protected function _getHtmlAttributes()
 {
     $attributes = [];
     $attributes['type'] = 'time';
     if ($this->getValue()) {
         $attributes['value'] = Ajde_Component_String::escape(date('H:i', strtotime($this->getValue())));
     } else {
         $attributes['value'] = '';
     }
     if ($this->hasReadonly() && $this->getReadonly() === true) {
         $attributes['readonly'] = 'readonly';
     }
     return $attributes;
 }
コード例 #12
0
ファイル: Mollie.php プロジェクト: nabble/ajde
 public function getRedirectUrl($description = null)
 {
     $transaction = $this->getTransaction();
     $mollie = new Mollie_API_Client();
     $mollie->setApiKey($this->getApiKey());
     $order_id = $transaction->secret;
     $data = ['amount' => $transaction->payment_amount, 'description' => isset($description) ? $description : config('app.title') . ': ' . Ajde_Component_String::makePlural($transaction->shipment_itemsqty, 'item'), 'redirectUrl' => config('app.rootUrl') . $this->returnRoute . 'mollie_' . $this->getMethod() . '.html?order_id=' . $order_id, 'method' => $this->getMethod(), 'metadata' => ['order_id' => $order_id]];
     $payment = $mollie->payments->create($data);
     // save details
     $transaction->payment_providerid = $payment->id;
     $transaction->save();
     $url = $payment->getPaymentUrl();
     return $this->ping($url) ? $url : false;
 }
コード例 #13
0
ファイル: Text.php プロジェクト: nabble/ajde
 protected function _getHtmlAttributes()
 {
     $attributes = [];
     $attributes['type'] = 'text';
     $attributes['value'] = Ajde_Component_String::escape($this->getValue());
     $attributes['maxlength'] = Ajde_Component_String::escape($this->getLength());
     if ($this->hasReadonly() && $this->getReadonly() === true) {
         $attributes['readonly'] = 'readonly';
     }
     if ($this->hasEmphasis() && $this->getEmphasis() === true) {
         $attributes['class'] = 'emphasis';
     }
     if ($this->hasPlaceholder()) {
         $attributes['placeholder'] = $this->getPlaceholder();
     }
     return $attributes;
 }
コード例 #14
0
ファイル: Abstract.php プロジェクト: nabble/ajde
 public function getModule($module = null)
 {
     if (!$module) {
         foreach (debug_backtrace() as $item) {
             if (!empty($item['class'])) {
                 if (is_subclass_of($item['class'], 'Ajde_Controller')) {
                     $module = current(explode('_', Ajde_Component_String::toSnakeCase($item['class'])));
                     break;
                 }
             }
         }
     }
     if (!$module) {
         $module = 'main';
     }
     return $module;
 }
コード例 #15
0
ファイル: ShopController.php プロジェクト: nabble/ajde
 public function item()
 {
     // we want to display published nodes only
     if (!(UserModel::getLoggedIn() && UserModel::getLoggedIn()->isAdmin())) {
         Ajde::app()->getRequest()->set('filterPublished', true);
     }
     // get the current slug
     $slug = $this->getSlug();
     /* @var $product ProductModel */
     $product = new ProductModel();
     $product->loadBySlug($slug);
     $this->product = $product;
     if ($product->getPublished() === false) {
         Ajde_Dump::warn('Previewing unpublished product');
     }
     // check if we have a hit
     if (!$product->hasLoaded()) {
         Ajde::app()->getResponse()->redirectNotFound();
     }
     Ajde_Event::trigger($this, 'onAfterProductLoaded', [$product]);
     // update cache
     Ajde_Cache::getInstance()->updateHash($product->hash());
     Ajde_Cache::getInstance()->addLastModified(strtotime($product->updated));
     // set title
     if (!Ajde::app()->getDocument()->hasNotEmpty('title')) {
         Ajde::app()->getDocument()->setTitle($product->getTitle());
     }
     // set summary
     if ($product->content) {
         Ajde::app()->getDocument()->setDescription(Ajde_Component_String::trim(strip_tags($product->content), '100'));
     }
     // set author
     $product->loadParent('user');
     /** @var UserModel $owner */
     $owner = $product->getUser();
     Ajde::app()->getDocument()->setAuthor($owner->getFullname());
     // featured image
     if ($image = $product->featuredImage()) {
         Ajde::app()->getDocument()->setFeaturedImage($image);
     }
     // pass node to view
     $this->setAction('item');
     $this->getView()->assign('product', $product);
     // render the template
     return $this->render();
 }
コード例 #16
0
ファイル: AdminShopController.php プロジェクト: nabble/ajde
 public function markPaidJson()
 {
     $id = Ajde::app()->getRequest()->getPostParam('id', false);
     $transaction = new TransactionModel();
     if (!is_array($id)) {
         $id = [$id];
     }
     $c = 0;
     foreach ($id as $elm) {
         $transaction->loadByPK($elm);
         if ($transaction->payment_status !== 'completed') {
             $transaction->paid();
             $c++;
         }
     }
     return ['success' => true, 'message' => Ajde_Component_String::makePlural($c, 'transaction') . ' marked as paid'];
 }
コード例 #17
0
ファイル: Wedeal.php プロジェクト: nabble/ajde
 public function getRedirectUrl($description = null)
 {
     $transaction = $this->getTransaction();
     $request = ['type' => 'transaction', 'transactionreq' => ['username' => config('shop.transaction.wedeal.username'), 'password' => config('shop.transaction.wedeal.password'), 'reference' => $transaction->secret, 'description' => config('app.id') . ': ' . Ajde_Component_String::makePlural($transaction->shipment_itemsqty, 'item'), 'amount' => str_replace('.', ',', (string) $transaction->payment_amount), 'methodcode' => '0101', 'maxcount' => '1', 'test' => $this->isSandbox() ? 'true' : 'false', 'successurl' => config('app.rootUrl') . 'shop/transaction:callback/wedeal.html', 'failurl' => config('app.rootUrl') . 'shop/transaction:callback/wedeal.html']];
     $res = $this->sendRequest($request, true);
     if ($res['success'] === true) {
         $url = $res['response'];
         if (substr($url, 0, 7) === 'http://' || substr($url, 0, 8) === 'https://') {
             return $this->ping($url) ? $res['response'] : false;
         } else {
             Ajde_Log::log('Wedeal::getRedirectUrl() returned no URL but: ' . $res['response']);
             return false;
         }
     } else {
         Ajde_Log::log('Wedeal::getRedirectUrl() returned no URL but: ' . $res['response']);
         return false;
     }
 }
コード例 #18
0
ファイル: Embed.php プロジェクト: nabble/ajde
 public function process()
 {
     switch ($this->_attributeParse()) {
         case 'render':
             $image = new Ajde_Resource_Image($this->attributes['filename']);
             $image->setWidth($this->attributes['width']);
             $image->setHeight($this->attributes['height']);
             $image->setCrop(Ajde_Component_String::toBoolean($this->attributes['crop']));
             $controller = Ajde_Controller::fromRoute(new Ajde_Core_Route('_core/component:imageBase64'));
             $controller->setImage($image);
             $controller->setWidth(issetor($this->attributes['width'], null));
             $controller->setHeight(issetor($this->attributes['height'], null));
             $controller->setExtraClass(issetor($this->attributes['class'], ''));
             return $controller->invoke();
             break;
     }
     // TODO:
     throw new Ajde_Component_Exception('Missing required attributes for component call');
 }
コード例 #19
0
ファイル: Wedeal.php プロジェクト: nabble/updatemybrowser-v1
 public function getRedirectUrl()
 {
     $transaction = $this->getTransaction();
     $total = (string) $total;
     $total = str_replace(".", ",", $total);
     $request = array("type" => "transaction", "transactionreq" => array("username" => Config::get('shopWedealUsername'), "password" => Config::get('shopWedealPassword'), "reference" => $transaction->secret, "description" => Config::get('ident') . ': ' . Ajde_Component_String::makePlural($transaction->shipment_itemsqty, 'item'), "amount" => str_replace(".", ",", (string) $transaction->payment_amount), "methodcode" => "0101", "maxcount" => "1", "test" => $this->isSandbox() ? "true" : "false", "successurl" => 'http://' . Config::get('site_root') . 'shop/transaction:callback/wedeal.html', "failurl" => 'http://' . Config::get('site_root') . 'shop/transaction:callback/wedeal.html'));
     $res = $this->sendRequest($request, true);
     if ($res['success'] === true) {
         $url = $res['response'];
         if (substr($url, 0, 7) === 'http://' || substr($url, 0, 8) === 'https://') {
             return $this->ping($url) ? $res['response'] : false;
         } else {
             Ajde_Log::log("Wedeal::getRedirectUrl() returned no URL but: " . $res['response']);
             return false;
         }
     } else {
         Ajde_Log::log("Wedeal::getRedirectUrl() returned no URL but: " . $res['response']);
         return false;
     }
 }
コード例 #20
0
ファイル: _coreCrudController.php プロジェクト: nabble/ajde
 private function delete($crudId, $id)
 {
     $session = new Ajde_Session('AC.Crud');
     $crud = $session->getModel($crudId);
     $model = $crud->getModel();
     if (!is_array($id)) {
         $id = [$id];
     }
     $success = true;
     $deleted = 0;
     foreach ($id as $elm) {
         $model->loadByPK($elm);
         if ($result = $model->delete()) {
             $deleted++;
         }
         $success = $success * $result;
     }
     return ['operation' => 'delete', 'success' => (bool) $success, 'message' => Ajde_Component_String::makePlural($deleted, 'record') . ' deleted'];
 }
コード例 #21
0
ファイル: Helper.php プロジェクト: nabble/updatemybrowser-v1
 public function clean($var)
 {
     return Ajde_Component_String::processStatic($this->getParser(), array('clean' => true, 'var' => $var));
 }
コード例 #22
0
ファイル: Request.php プロジェクト: nabble/ajde
 public function getParam($key, $default = null, $type = self::TYPE_STRING, $post = false)
 {
     $data = $this->_data;
     if ($post === true) {
         $data = $this->getPostData();
     }
     if (isset($data[$key])) {
         switch ($type) {
             case self::TYPE_HTML:
                 if ($this->autoCleanHtml() === true) {
                     return Ajde_Component_String::clean($data[$key]);
                 } else {
                     return $data[$key];
                 }
                 break;
             case self::TYPE_INTEGER:
                 return (int) $data[$key];
                 break;
             case self::TYPE_FLOAT:
                 return (double) $data[$key];
                 break;
             case self::TYPE_RAW:
                 return $data[$key];
                 break;
             case self::TYPE_STRING:
             default:
                 if ($this->autoEscapeString() === true) {
                     if (is_array($data[$key])) {
                         array_walk($data[$key], ['Ajde_Component_String', 'escape']);
                         return $data[$key];
                     } else {
                         return Ajde_Component_String::escape($data[$key]);
                     }
                 } else {
                     return $data[$key];
                 }
         }
     } else {
         if (isset($default)) {
             return $default;
         } else {
             // TODO:
             throw new Ajde_Exception("Parameter '{$key}' not present in request and no default value given");
         }
     }
 }
コード例 #23
0
ファイル: index.php プロジェクト: nabble/updatemybrowser-v1
function _c($var)
{
    return Ajde_Component_String::clean($var);
}
コード例 #24
0
ファイル: Paypal.php プロジェクト: nabble/updatemybrowser-v1
 public function getRedirectParams()
 {
     $transaction = $this->getTransaction();
     return array('cmd' => '_xclick', 'business' => Config::get('shopPaypalAccount'), 'notify_url' => 'http://' . Config::get('site_root') . 'shop/transaction:callback/paypal.html', 'bn' => Config::get('ident') . '_BuyNow_WPS_' . strtoupper(Ajde_Lang::getInstance()->getShortLang()), 'amount' => $transaction->payment_amount, 'item_name' => Config::get('ident') . ': ' . Ajde_Component_String::makePlural($transaction->shipment_itemsqty, 'item'), 'quantity' => 1, 'address_ override' => 1, 'address1' => $transaction->shipment_address, 'zip' => $transaction->shipment_zipcode, 'city' => $transaction->shipment_city, 'state' => $transaction->shipment_region, 'country' => $transaction->shipment_country, 'email' => $transaction->email, 'first_name' => $transaction->name, 'currency_code' => Config::get('currencyCode'), 'custom' => $transaction->secret, 'no_shipping' => 1, 'no_note' => 1, 'return' => 'http://' . Config::get('site_root') . 'shop/transaction:complete', 'rm' => 1);
 }
コード例 #25
0
ファイル: SubmissionModel.php プロジェクト: nabble/ajde
 public function displayAgo()
 {
     $timestamp = new DateTime($this->get('added'));
     $timestamp = $timestamp->format('U');
     return Ajde_Component_String::time2str($timestamp);
 }
コード例 #26
0
 public function registerJson()
 {
     $user = new UserModel();
     $returnto = Ajde::app()->getRequest()->getPostParam('returnto', false);
     $username = Ajde::app()->getRequest()->getPostParam($user->usernameField);
     $password = Ajde::app()->getRequest()->getPostParam('password');
     $passwordCheck = Ajde::app()->getRequest()->getPostParam('passwordCheck');
     $email = Ajde::app()->getRequest()->getPostParam('email', false);
     $fullname = Ajde::app()->getRequest()->getPostParam('fullname', false);
     $return = array(false);
     $shadowUser = new UserModel();
     if (empty($username) || empty($password)) {
         $return = array('success' => false, 'message' => __("Please provide " . $user->usernameField . " and password"));
     } else {
         if ($shadowUser->loadByField($shadowUser->usernameField, $username)) {
             $return = array('success' => false, 'message' => __(ucfirst($user->usernameField) . " already exist"));
         } else {
             if ($password !== $passwordCheck) {
                 $return = array('success' => false, 'message' => __("Passwords do not match"));
             } else {
                 if (empty($email)) {
                     $return = array('success' => false, 'message' => __("Please provide an e-mail address"));
                 } else {
                     if (Ajde_Component_String::validEmail($email) === false) {
                         $return = array('success' => false, 'message' => __('Please provide a valid e-mail address'));
                     } else {
                         if ($shadowUser->loadByField('email', $email)) {
                             $return = array('success' => false, 'message' => __("A user with this e-mail address already exist"));
                         } else {
                             if (empty($fullname)) {
                                 $return = array('success' => false, 'message' => __("Please provide a full name"));
                             } else {
                                 $user->set('email', $email);
                                 $user->set('fullname', $fullname);
                                 if ($user->add($username, $password)) {
                                     $user->login();
                                     Ajde_Session_Flash::alert(sprintf(__('Welcome %s, you are now logged in.'), $fullname));
                                     $return = array('success' => true, 'returnto' => $returnto);
                                 } else {
                                     $return = array('success' => false, 'message' => __("Something went wrong"));
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     return $return;
 }
コード例 #27
0
 public function setupJson($source = false)
 {
     $request = Ajde::app()->getRequest();
     // Init vars
     $name = null;
     $email = null;
     $address = null;
     $zipcode = null;
     $city = null;
     $region = null;
     $country = null;
     $shipmentMethod = null;
     $comment = null;
     if ($source === false) {
         // Read request
         $name = $request->getPostParam('name', false);
         $email = $request->getPostParam('email', false);
         $address = $request->getPostParam('shipment_address', false);
         $zipcode = $request->getPostParam('shipment_zipcode', false);
         $city = $request->getPostParam('shipment_city', false);
         $region = $request->getPostParam('shipment_region', false);
         $country = $request->getPostParam('shipment_country', false);
         $shipmentMethod = $request->getPostParam('shipment_method', false);
         $comment = $request->getPostParam('comment', false);
     } else {
         if ($source instanceof Ajde_User) {
             // Read user
             $name = $source->fullname;
             $email = $source->email;
             $address = $source->address;
             $zipcode = $source->zipcode;
             $city = $source->city;
             $region = $source->region;
             $country = $source->country;
             $shipmentMethod = false;
             $comment = false;
         }
     }
     // Return when fields are not complete
     if ($source === false) {
         if (empty($name) || empty($email) || empty($address) || empty($zipcode) || empty($city) || empty($country)) {
             return ['success' => false, 'message' => trans('Not all your details are filled out')];
         }
         if (Ajde_Component_String::validEmail($email) === false) {
             return ['success' => false, 'message' => trans('Please provide a valid e-mail address')];
         }
         if (empty($shipmentMethod)) {
             return ['success' => false, 'message' => trans('Please choose a shipment method')];
         }
     }
     // Check for current transaction
     $transaction = new TransactionModel();
     $session = new Ajde_Session('AC.Shop');
     if ($session->has('currentTransaction') && $transaction->loadByPK($session->get('currentTransaction'))) {
         // Edit existing transaction
         $method = 'save';
     } else {
         // Insert new transaction
         $method = 'insert';
     }
     // Update transaction info
     $transaction->name = $name;
     $transaction->email = $email;
     $transaction->shipment_address = $address;
     $transaction->shipment_zipcode = $zipcode;
     $transaction->shipment_city = $city;
     $transaction->shipment_region = $region;
     $transaction->shipment_country = $country;
     $transaction->shipment_method = $shipmentMethod;
     $transaction->comment = $comment;
     // Save info to user
     if ($user = $this->getLoggedInUser()) {
         if ($request->hasPostParam('save_details', false)) {
             $user->address = $address;
             $user->zipcode = $zipcode;
             $user->city = $city;
             $user->region = $region;
             $user->country = $country;
             $user->save();
             $user->login();
         }
         $transaction->user = $user->getPK();
     }
     // Update shipping total
     $shipping = new ShippingModel($transaction);
     $transaction->shipment_cost = 0;
     if (!empty($shipmentMethod) && $shipping->isAvailable($shipmentMethod)) {
         $transaction->shipment_cost = $shipping->getMethod($shipmentMethod)->getTotal();
     }
     // Insert new transaction
     if ($method === 'insert') {
         if ($transaction->insert()) {
             $this->updateFromCart($transaction);
             $session = new Ajde_Session('AC.Shop');
             $session->set('currentTransaction', $transaction->getPK());
             if (!$transaction->shipment_itemsqty > 0) {
                 return ['success' => false, 'message' => trans('No items added to current order')];
             }
             return ['success' => true];
         }
         return ['success' => false, 'message' => trans('Something went wrong')];
     }
     $transaction->payment_amount = $transaction->shipment_itemstotal + $transaction->shipment_cost;
     // Update current transaction
     if ($transaction->save()) {
         if (!$transaction->shipment_itemsqty > 0) {
             return ['success' => false, 'message' => trans('No items added to current transaction')];
         }
         return ['success' => true];
     }
     // Everything else failed
     return ['success' => false, 'message' => trans('Something went wrong')];
 }
コード例 #28
0
ファイル: AdminMediaController.php プロジェクト: nabble/ajde
 public function typeBtnJson()
 {
     $value = Ajde::app()->getRequest()->getPostParam('type');
     $id = Ajde::app()->getRequest()->getPostParam('id', false);
     $model = new MediaModel();
     if (!is_array($id)) {
         $id = [$id];
     }
     foreach ($id as $elm) {
         $model->loadByPK($elm);
         $model->set('mediatype', $value);
         $model->save();
     }
     return ['success' => true, 'message' => Ajde_Component_String::makePlural(count($id), 'media') . ' changed'];
 }
コード例 #29
0
 public function delete($crudId, $id)
 {
     $session = new Ajde_Session('AC.Crud');
     $crud = $session->getModel($crudId);
     $model = $crud->getModel();
     if (!is_array($id)) {
         $id = array($id);
     }
     $success = true;
     foreach ($id as $elm) {
         $model->loadByPK($elm);
         $success = $success * $model->delete();
     }
     return array('operation' => 'delete', 'success' => (bool) $success, 'message' => Ajde_Component_String::makePlural(count($id), 'record') . ' deleted');
 }
コード例 #30
0
ファイル: UserController.php プロジェクト: nabble/ajde
 public function registerJson()
 {
     $user = new UserModel();
     $returnto = Ajde::app()->getRequest()->getPostParam('returnto', false);
     $username = Ajde::app()->getRequest()->getPostParam($user->usernameField);
     $password = Ajde::app()->getRequest()->getPostParam('password', '');
     $passwordCheck = Ajde::app()->getRequest()->getPostParam('passwordCheck', '');
     $providername = Ajde::app()->getRequest()->getPostParam('provider', false);
     $email = Ajde::app()->getRequest()->getPostParam('email', false);
     $fullname = Ajde::app()->getRequest()->getPostParam('fullname', false);
     $return = [false];
     $shadowUser = new UserModel();
     $provider = false;
     if ($providername) {
         $sso = config('user.sso.providers');
         if (!in_array($providername, $sso)) {
             Ajde_Http_Response::redirectNotFound();
         }
         $classname = 'Ajde_User_Sso_' . ucfirst($providername);
         /* @var $provider Ajde_User_SSO_Interface */
         $provider = new $classname();
     }
     if (empty($username)) {
         $return = ['success' => false, 'message' => trans('Please provide a ' . $user->usernameField . '')];
     } else {
         if (!$provider && empty($password)) {
             $return = ['success' => false, 'message' => trans('Please provide a password')];
         } else {
             if ($shadowUser->loadByField($shadowUser->usernameField, $username)) {
                 $return = ['success' => false, 'message' => trans(ucfirst($user->usernameField) . ' already exist')];
             } else {
                 if (!$provider && $password !== $passwordCheck) {
                     $return = ['success' => false, 'message' => trans('Passwords do not match')];
                 } else {
                     if (empty($email)) {
                         $return = ['success' => false, 'message' => trans('Please provide an e-mail address')];
                     } else {
                         if (Ajde_Component_String::validEmail($email) === false) {
                             $return = ['success' => false, 'message' => trans('Please provide a valid e-mail address')];
                         } else {
                             if ($shadowUser->loadByField('email', $email)) {
                                 $return = ['success' => false, 'message' => trans('A user with this e-mail address already exist')];
                             } else {
                                 if (empty($fullname)) {
                                     $return = ['success' => false, 'message' => trans('Please provide a full name')];
                                 } else {
                                     if ($provider && !$provider->getData()) {
                                         $return = ['success' => false, 'message' => trans('Something went wrong with fetching your credentials from an external service')];
                                     } else {
                                         $user->set('email', $email);
                                         $user->set('fullname', $fullname);
                                         if ($user->add($username, $password)) {
                                             if ($provider) {
                                                 $sso = new SsoModel();
                                                 $sso->populate(['user' => $user->getPK(), 'provider' => $providername, 'username' => $provider->getUsernameSuggestion(), 'avatar' => $provider->getAvatarSuggestion(), 'profile' => $provider->getProfileSuggestion(), 'uid' => $provider->getUidHash(), 'data' => serialize($provider->getData())]);
                                                 $sso->insert();
                                                 $user->copyAvatarFromSso($sso);
                                             }
                                             $user->login();
                                             $user->storeCookie($this->includeDomain);
                                             Ajde_Session_Flash::alert(sprintf(trans('Welcome %s, you are now logged in'), $fullname));
                                             $return = ['success' => true, 'returnto' => $returnto];
                                         } else {
                                             $return = ['success' => false, 'message' => trans('Something went wrong')];
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     return $return;
 }