/** * Save a order purchased by user. * * @param int $userId * @param int $extentionId * * @author Kuldeep Dangi <*****@*****.**> */ public function saveOrder($userId, $extentionId) { $extentionObj = Extensions::model()->findByPk($extentionId); $userObj = Users::model()->findByPk($userId); if ($extentionObj && $userObj) { $data = array("user_id" => $userObj->user_id, "extension_id" => $extentionObj->extension_id, "extension_name" => $extentionObj->name, "extension_price" => $extentionObj->price, "quantity" => 1, "total_price" => $extentionObj->price, "created_date" => time(), 'added_date' => date('Y-m-d H:i:s'), "status" => 1, "payment_type" => 0, "address_id" => 0); $this->attributes = $data; if ($this->save()) { return true; } } return false; }
/** * Handle webhook request from instamojo * * @author Kuldeep Dangi <*****@*****.**> */ public function actionCheckoutApp($userId) { $cartModel = new Cartdetails(); $userModel = new Users(); $userByExtentionId = new UsersBuyExtensions(); $userObj = Users::model()->findByPk($userId); $cartData = $cartModel->getUserCartProductIds($userId); $settingsModel = Setting::model()->findByPk(1); if (!$userObj || count($cartData) < 1) { exit; } $notficationModel = new Notifications(); $notficationModel->sendPushNotification(array('deviceToken' => $userObj->deviceToken, 'deviceType' => $userObj->deviceType, 'message' => 3)); foreach ($cartData as $cartRow) { $orderModel = new Order(); $model = Cartdetails::model()->findByPk($cartRow['id']); $extentionObj = Extensions::model()->findByPk($model->productid); $nCashAmount = $model->price - $model->price * $settingsModel->commission / 100; $data = array("user_id" => $userObj->user_id, "coupondata" => '', "uservalrewdata" => '', "userval" => '', "extension_id" => $model->productid, "rewardpoints" => '', "extension_name" => $extentionObj->name, "extension_price" => $model->price, "quantity" => 1, "total_price" => $model->price, "shipping_fee" => '', "transaction_paypal_id" => $_POST['payment_id'], "commission" => $settingsModel->commission, "total_balance" => $nCashAmount, "created_date" => time(), 'added_date' => $this->getCurrentDateTime(), "status" => 1, "payment_type" => 1, "address_id" => 0); $orderModel->attributes = $data; if ($orderModel->save()) { $userModel = Users::model()->findByPk($extentionObj->user_id); $nCash = new Ncash(); // Ncash deducted from buyer account $nCash->deductAmount($userObj->user_id, $model->price); // Ncash awarded to buyer $nCash->addAmount($userObj->user_id, self::REWARD_ON_NOTE_PURCHASE, 2); // Ncash for seller $nCash->addAmount($userModel->user_id, $nCashAmount, 5); if ($userModel) { $notficationModel->sendPushNotification(array('deviceToken' => $userModel->deviceToken, 'deviceType' => $userModel->deviceType, 'message' => 4)); } $model->used = 1; $model->save(); //increment extention download // email notification $userBuyExtentionObj = $userByExtentionId->findByAttributes(array('user_id' => $userObj->user_id, 'extension_id' => $model->productid)); if ($userBuyExtentionObj) { $userBuyExtentionObj->download = $userBuyExtentionObj->download + $settingsModel->download_times; if ($userBuyExtentionObj->expire_time > time()) { $userBuyExtentionObj->expire_time = $userBuyExtentionObj->expire_time + $settingsModel->download_expire; } else { $userBuyExtentionObj->expire_time = time() + $settingsModel->download_expire; } $userBuyExtentionObj->save(); } else { $userByExtentionId->attributes = array('user_id' => $userObj->user_id, 'extension_id' => $model->productid, 'download' => $settingsModel->download_times, 'expire_time' => time() + $settingsModel->download_expire); $userByExtentionId->save(); } } $this->result['success'] = true; } $this->sendResponse($this->result); }
/** * Delete post action */ public function actiondeletepost() { // Perms if (!Yii::app()->user->checkAccess('op_extensions_deleteposts')) { throw new CHttpException(403, Yii::t('error', 'Sorry, You don\'t have the required permissions to enter this section')); } if (isset($_GET['id']) && ($model = Extensions::model()->findByPk($_GET['id']))) { $catid = $model->catid; $model->delete(); Yii::app()->user->setFlash('success', Yii::t('extensions', 'Extension Deleted.')); $this->redirect(array('viewcategory', 'id' => $catid)); } else { $this->redirect(array('index')); } }
/** * Load model of a Note. * * @author Kuldeep Dangi <*****@*****.**> */ public function loadModel($id) { $model = Extensions::model()->findByPk($id); return $model; }
?> </td> <?php } ?> </tr> <?php } ?> <?php } else { ?> <tr> <td colspan='<?php if (Extensions::model()->canEditPost($model)) { ?> 7<?php } else { ?> 6<?php } ?> '><?php echo Yii::t('extensions', 'No Files Uploaded Yet.'); ?> </td> </tr> <?php } ?>
<?php $options = array(); if (Yii::app()->user->checkAccess('op_extensions_addposts')) { $options[Yii::t('extensions', 'Add Extension')] = array('extensions/addpost'); } if (Yii::app()->user->checkAccess('op_extensions_manage')) { $pending = Extensions::model()->count('status=0'); $options[Yii::t('extensions', '{count} Pending Extensions', array('{count}' => $pending))] = array('extensions/showpending'); } if (Yii::app()->user->id) { $options[Yii::t('extensions', 'My Extensions')] = array('extensions/showmyposts'); } ?> <div id="nav"> <div class="boxnavnoborder"> <ul class='menunav'> <h4><?php echo Yii::t('extensions', 'Categories'); ?> </h4> <?php foreach (ExtensionsCats::model()->getCatsForMember(Yii::app()->language) as $category) { ?> <li><?php echo CHtml::link($category->title, array('/extensions/category/' . $category->alias, 'lang' => false)); ?> - ( <?php echo $category->count;
?> </h3> <ul> <?php $extensions = Extensions::model()->findAll('authorid=:uid AND status=1', array(':uid' => $model->id)); ?> <?php if (is_array($extensions) && count($extensions)) { ?> <?php foreach ($extensions as $extension) { ?> <li><?php echo Extensions::model()->getLink($extension->title, $extension->alias, array('title' => $extension->description)); ?> </li> <?php } ?> <?php } else { ?> <li><?php echo Yii::t('users', 'No Extensions Submitted.'); ?> </li> <?php }
/** * Download post as pdf */ public function actionword() { if (isset($_GET['id']) && ($model = Extensions::model()->findByPk($_GET['id']))) { $markdown = new MarkdownParser(); $model->content = $markdown->safeTransform($model->content); $this->layout = false; $content = $this->render('index', array('content' => $model->content), true); Yii::app()->func->downloadAs($model->title, $model->alias, $content, 'word'); } else { $this->redirect(Yii::app()->request->getUrlReferrer()); } }
/** * Get the rows for the sitemap */ protected function getRows() { $_rows = array(); // Grab blog cats $blogCats = BlogCats::model()->findAll('language=:langauge', array(':langauge' => Yii::app()->language)); if (count($blogCats)) { foreach ($blogCats as $blogCat) { $_rows[] = $this->makeData($this->getFullUrl('/blog/category/' . $blogCat->alias), time(), 'monthly', 0.1); } } // Grab blog rows $blogRows = Blog::model()->findAll('language=:langauge', array(':langauge' => Yii::app()->language)); if (count($blogRows)) { foreach ($blogRows as $blogRow) { $_rows[] = $this->makeData($this->getFullUrl('/blog/view/' . $blogRow->alias), $blogRow->postdate, 'weekly', 1); } } // Grab tutorials cats $tutorialsCats = TutorialsCats::model()->findAll('language=:langauge', array(':langauge' => Yii::app()->language)); if (count($tutorialsCats)) { foreach ($tutorialsCats as $tutorialsCat) { $_rows[] = $this->makeData($this->getFullUrl('/tutorials/category/' . $tutorialsCat->alias), time(), 'monthly', 0.1); } } // Grab tutorials rows $tutorialsRows = Tutorials::model()->findAll('language=:langauge', array(':langauge' => Yii::app()->language)); if (count($tutorialsRows)) { foreach ($tutorialsRows as $tutorialsRow) { $_rows[] = $this->makeData($this->getFullUrl('/tutorials/view/' . $tutorialsRow->alias), $tutorialsRow->postdate, 'weekly', 1); } } // Grab extensions cats $extensionsCats = ExtensionsCats::model()->findAll('language=:langauge', array(':langauge' => Yii::app()->language)); if (count($extensionsCats)) { foreach ($extensionsCats as $extensionsCat) { $_rows[] = $this->makeData($this->getFullUrl('/extensions/category/' . $extensionsCat->alias), time(), 'monthly', 0.1); } } // Grab extensions rows $extensionsRows = Extensions::model()->findAll('language=:langauge', array(':langauge' => Yii::app()->language)); if (count($extensionsRows)) { foreach ($extensionsRows as $extensionsRow) { $_rows[] = $this->makeData($this->getFullUrl('/extensions/view/' . $extensionsRow->alias), $extensionsRow->postdate, 'weekly', 1); } } // Grab users rows $usersRows = Members::model()->findAll(); if (count($usersRows)) { foreach ($usersRows as $usersRow) { $_rows[] = $this->makeData($this->getFullUrl('/user/' . $usersRow->id . '-' . $usersRow->seoname), $usersRow->joined, 'monthly', 1); } } // Grab forum topics rows $forumTopics = ForumTopics::model()->findAll('language=:langauge', array(':langauge' => Yii::app()->language)); if (count($forumTopics)) { foreach ($forumTopics as $forumTopic) { $_rows[] = $this->makeData($this->getFullUrl('/forum/topic/' . $forumTopic->id . '-' . $forumTopic->alias), $forumTopic->dateposted, 'daily', 1); } } // Grab custom pages $customPages = CustomPages::model()->findAll('language=:langauge', array(':langauge' => Yii::app()->language)); if (count($customPages)) { foreach ($customPages as $customPage) { $_rows[] = $this->makeData($this->getFullUrl('/' . $forumTopic->alias), $customPage->dateposted, 'weekly', 1); } } // Grab documentation pages $documentations = Documentation::model()->findAll('language=:langauge', array(':langauge' => Yii::app()->language)); if (count($documentations)) { foreach ($documentations as $documentation) { $_rows[] = $this->makeData($this->getFullUrl('/documentation/guide/' . $documentation->type . '/topic/' . $documentation->mkey), $documentation->last_updated, 'weekly', 1); } } // Return array return $_rows; }
/** * Dado un conjunto de parametros los salva en el servidor AMI */ public function saveAMI($variables) { $departamento = $variables['departamento']; // Se obtienen todas las extensiones pertenecientes al departamento // que viene especificado en $variables $extensiones = Extensions::model()->findAll(array('condition' => "DEP = '{$departamento}'")); $this->iniciarConexionAMI(); $this->borrar_todo($extensiones); foreach ($variables as $key => $value) { if (in_array($key, $this->familias)) { // Si es una familia valida if ($key == "DND" or $key == "LKP" or $key == "LMNT") { // Si es una de las booleanas foreach ($value as $id) { $extensiones = Extensions::model()->findByPk($id); $this->databaseSet($key, trim($extensiones->numero), "YES"); // Colocamos en true los elementos } } else { // Si no es una de las booleanas foreach ($value as $id => $numero) { if (is_numeric($numero)) { $extensiones = Extensions::model()->findByPk($id); $this->databaseSet($key, trim($extensiones->numero), $numero); } if (!is_numeric($numero) && !$numero == "") { Yii::app()->user->setFlash('error', "Uno de los valores introducidos no tiene formato correcto: {$numero}"); } } } } } $this->finalizarConexionAMI(); }